Update xml_scan.py
Browse files- xml_scan.py +7 -12
xml_scan.py
CHANGED
@@ -8,7 +8,6 @@ import urllib3
|
|
8 |
|
9 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
10 |
|
11 |
-
# Function to generate URL using HMAC
|
12 |
def generate_url(GameID):
|
13 |
byte_key = binascii.unhexlify("AD62E37F905E06BC19593142281C112CEC0E7EC3E97EFDCAEFCDBAAFA6378D84")
|
14 |
hash = hmac.new(byte_key, ("np_" + GameID).encode('utf-8'), digestmod=hashlib.sha256)
|
@@ -16,34 +15,30 @@ def generate_url(GameID):
|
|
16 |
url = f"https://gs-sec.ww.np.dl.playstation.net/plo/np/{GameID}/{hash}/{GameID}-ver.xml"
|
17 |
return url
|
18 |
|
19 |
-
# 将16进制的密钥转换为字节数组
|
20 |
-
|
21 |
-
|
22 |
-
# 循环遍历CUSA00001到CUSA01000的范围
|
23 |
for number in tqdm(range(1, 45000)):
|
24 |
GameID = f"CUSA{number:05}"
|
25 |
url = generate_url(GameID)
|
26 |
|
27 |
try:
|
28 |
-
|
29 |
response = requests.get(url,verify=False)
|
30 |
-
response.raise_for_status()
|
31 |
xml_content = response.content
|
32 |
|
33 |
root = ET.fromstring(xml_content)
|
34 |
-
|
35 |
title_id = root.attrib["titleid"]
|
36 |
title = root.find(".//title").text
|
37 |
version = root.find(".//package").attrib["version"]
|
38 |
content_id = root.find(".//package").attrib["content_id"]
|
39 |
|
40 |
-
|
41 |
with open("extracted_info.txt", "a", encoding="utf-8") as info_file:
|
42 |
info_file.write(f"{title_id},{title},{version},{content_id}\n")
|
43 |
|
44 |
-
print(f"{GameID}:{title} -
|
45 |
except (requests.exceptions.RequestException, ET.ParseError) as e:
|
46 |
print(f"{GameID} - Error: {e}")
|
47 |
-
continue
|
48 |
-
|
49 |
print("Extraction and writing completed!")
|
|
|
8 |
|
9 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
10 |
|
|
|
11 |
def generate_url(GameID):
|
12 |
byte_key = binascii.unhexlify("AD62E37F905E06BC19593142281C112CEC0E7EC3E97EFDCAEFCDBAAFA6378D84")
|
13 |
hash = hmac.new(byte_key, ("np_" + GameID).encode('utf-8'), digestmod=hashlib.sha256)
|
|
|
15 |
url = f"https://gs-sec.ww.np.dl.playstation.net/plo/np/{GameID}/{hash}/{GameID}-ver.xml"
|
16 |
return url
|
17 |
|
|
|
|
|
|
|
|
|
18 |
for number in tqdm(range(1, 45000)):
|
19 |
GameID = f"CUSA{number:05}"
|
20 |
url = generate_url(GameID)
|
21 |
|
22 |
try:
|
23 |
+
|
24 |
response = requests.get(url,verify=False)
|
25 |
+
response.raise_for_status()
|
26 |
xml_content = response.content
|
27 |
|
28 |
root = ET.fromstring(xml_content)
|
29 |
+
|
30 |
title_id = root.attrib["titleid"]
|
31 |
title = root.find(".//title").text
|
32 |
version = root.find(".//package").attrib["version"]
|
33 |
content_id = root.find(".//package").attrib["content_id"]
|
34 |
|
35 |
+
|
36 |
with open("extracted_info.txt", "a", encoding="utf-8") as info_file:
|
37 |
info_file.write(f"{title_id},{title},{version},{content_id}\n")
|
38 |
|
39 |
+
print(f"{GameID}:{title} - COMPLETE\n")
|
40 |
except (requests.exceptions.RequestException, ET.ParseError) as e:
|
41 |
print(f"{GameID} - Error: {e}")
|
42 |
+
continue
|
43 |
+
|
44 |
print("Extraction and writing completed!")
|