x科网下载代码 12k教辅下载好东西 py代码懂得用
import requests
from re import findall, sub
from hashlib import md5
HTML_FORMAT ='''
{title}
{body}
'''
def writefile(filename,text):
filename = sub(r"""[\*\/\\\|\\? \:\.\'\"\!]""", "", filename)
unique = md5(text.encode())
filename += "_"+unique.hexdigest()[:5]
filename+=".html"
print("Writing "+filename)
# print("-=-=-=-=\n",text,"\n-=-=-=-=")
with open(filename+'.html', 'w', encoding="utf-8") as f:
f.write(text)
def main():
softID=input("ID: ")
url = "https://www.xxxxx.com/soft/Preview/FirstLoadPreviewJson?softID={}&type=3&product=1&v=2&FullPreview=true"
response = requests.get(url.format(softID))
if response.status_code!=200:
print("ERROR")
print(response.status_code)
return -1
ret=response.json()["data"]
if not ret["IsSuccess"]:
print("ERROR: IsSuccess option is not true")
print(ret)
if not ret['IsRar']:
print("Not rar")
print("TotalPage=%d" % ret['TotalPage'])
print("SoftExt=%s" % ret['SoftExt'])
try:
html=ret["Html"]
print(ret)
except:
print(ret)
exit(1)
# replace "data-original" to "src" for showing in browser
html=html.replace("data-original", "src")
writefile(f"{softID}",html)
else:
print("is RAR")
rar=ret['rarPreviewInfo']
for file in rar:
html=file["Html"]
title=file["SoftName"]
# replace "data-original" to "src" for showing in browser
# html=html.replace("data-original", "src")
urls=findall("(?
等我啥时候有时间加个ui界面,不然总不能每次开pycharm吧,好分享,吃我一果
有成品吗
谁写个成品啊
写完分享一下
不太对劲,不能完整下载,而且url需要改成对应的zxxk和xkw
![]() | 2022-06-22 14:30 |
![]() | 2022-03-05 07:55 |
![]() | 2022-10-21 12:23 |
![]() | 2023-08-05 16:59 |
![]() | 2022-08-04 21:16 |
![]() | 2023-11-20 22:05 |
![]() | 2023-11-20 22:02 |
![]() | 2023-11-20 19:03 |
![]() | 2023-11-20 21:58 |
![]() | 2023-11-20 21:57 |