Scrap Mechanic Mod Search Using Python 3
Scrap Mechanic Mod Search Using Python 3
Code Example
- Code:
# Stage 1
import requests
response=requests.get("https://scrapmechanicmods.com/blueshap.txt")
shapeids=response.text.splitlines()
# Stage 2
import os
if not os.path.exists("iconxml"):
os.makedirs("iconxml")
for shapeid in shapeids:
url=f"https://scrapmechanicmods.com/iconmap/{shapeid}.xml"
response=requests.get(url)
with open(f"iconxml/{shapeid}.xml", "w") as file:
file.write(response.text)
# Stage 3
with open("blue.jso", "rb") as file:
raw_data=file.read()
byte_array=list(raw_data)
byte_positions=range(0, len(byte_array), 16)
bm_values=[]
for byte_position in byte_positions:
bm_values.append(",".join(str(byte_array[i]) for i in range(byte_position, byte_position + 16)))
with open("blue.txt", "w") as file:
file.write(" ".join(bm_values))
# Stage 4
import os
saved=[]
with open("blueshap.txt", "r") as file:
shapeids=file.read().splitlines()
with open("modsused.htm", "w") as file:
file.write("") # Clear the file if it exists
for shapcount, shapeid in enumerate(shapeids, start=1):
shapnum=str(shapcount).zfill(3)
print(f"[{shapnum}] locate: {shapeid} ", end="")
foundshape=False
foundinfile=""
with open("xmlindex.txt", "r") as index_file:
for xml_filename in index_file.read().splitlines():
with open(f"iconxml/{xml_filename}", "r") as xml_file:
for line in xml_file:
for i in range(len(line) - 35):
if shapeid.lower() == line[i:i+36].lower():
foundshape=True
foundinfile=os.path.splitext(xml_filename)[0]
break
if foundshape:
break
if foundshape:
break
if foundshape:
with open("modsused.htm", "a") as file:
file.write(f'<a href="https://steamcommunity.com/workshop/filedetails/?id={foundinfile}">click me</a><br>')
print(f"in: {foundinfile} <{len(saved) + 1}>")
saved.append(foundinfile)
else:
with open("modsused.htm", "a") as file:
file.write("** NOT FOUND **<br>")
print("** NOT FOUND **")
print(saved)
Similar topics
» Securing a Python Menu With Python Encrypted Password File
» This command adds Python 3 as an alternative for the python command
» search cia archives
» Exploring the deep web with 1 search engine
» Google Encrypted Firefox Search Addon
» This command adds Python 3 as an alternative for the python command
» search cia archives
» Exploring the deep web with 1 search engine
» Google Encrypted Firefox Search Addon
Permissions in this forum:
You cannot reply to topics in this forum
|
|