本来想用pyexecjs一步到位的,无奈报错ReferenceError: SMH is not defined 就只能这样了
import requests
import re
import lzstring
z = lzstring.LZString()
url = 'https://www.mhgui.com/comic/43543/'
zym = requests.get(url)
zymt = zym.text
dhz0 = re.findall('"display:block">(.*?)class="comment mt10"',zymt)
dhz0=str(dhz0)
dhz = re.findall('<li><a href="(.*?)"\stitle="',dhz0)#每话链接
dhzs = len(dhz)#总话数
x=0
while dhzs>0:
durl = 'https://www.mhgui.com'+dhz[dhzs-1]
ym = requests.get(durl)
ymt = ym.text
#print(ymt)
miwen = re.findall("\d\d,\d\d,(.*?)'\[",ymt)
miwen=''.join(miwen)
miwen = miwen.replace("'",'')
jiemi = z.decompressFromBase64(miwen).split('|')
#print(miwen)
#print(jiemi)
ymt1 = ymt.replace("'"+miwen,str(jiemi))
t1 ='window["\\x65\\x76\\x61\\x6c"]'
w1 = "'['\\x73\\x70\\x6c\\x69\\x63']('\\"#'('\\x7c
ymt2 = ymt1.replace(t1,"eval")
ymt3 = ymt2.replace(w1,'')
ymt4 = ymt3.replace("x7c')",'')
#print(ymt4)
print('\n\n\n')
ok = re.findall('js"></script><script type="text/javascript">(.*?) </script>',ymt4)
ok = ''.join(ok)
ok1 = ok.replace("false","1")
ok2 = ok1.replace("\s","")
print("第",x,"话列表")
print(ok2)
x+=1
dhzs-=1
将上面输出的内容复制在以下网站解密
js解密
zd就是刚才解密的字典
from posixpath import basename
import re
import requests
import os
zd = {"bid":43543,"bname":"令和的斑 小姐","bpic":"43543.jpg","cid":623971,"cname":"第01话","files":["1.jpg.webp","2.jpg.webp","3.jpg.webp","4.jpg.webp","6.jpg.webp","7.jpg.webp","8.jpg.webp","9.jpg.webp","10.jpg.webp","11.jpg.webp","12.jpg.webp","13.jpg.webp","14.jpg.webp","15.jpg.webp","16.jpg.webp","999.jpg.webp","12487497l.jpg.webp"],"finished":1,"len":17,"path":"/ps1/z/zc-18973/lhdbxj/第01话/","status":1,"block_cc":"","nextId":624241,"prevId":0,"sl":{"e":1651645945,"m":"hHNSlFc6dyH-JqiqrFHGhg"}}
tu = zd['files']#所有页的文件名
tus = len(zd['files'])#本话总页数
mem = zd['sl']#e码和m码
em = "?e="+str(mem['e'])#e码
mm = "&m="+mem['m']#m码
bname= zd['bname']#漫画名
cname = zd["cname"]#第几话
path = zd['path']#服务器文件路径
x = 0
wj = os.path.exists('d:/manga/%s'%bname)
print(wj)
if wj==0:
os.makedirs('d:/manga/%s'%bname)
while x<tus:
head ={
'Referer': 'https://www.mhgui.com/',
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36'
}
url = 'https://eu.hamreus.com/'+path+tu[x]+em+mm
tuym = requests.get(url=url,headers=head)
print(url)
print(tuym.status_code)
f=open('d:/manga/%s/%s%s-%s.png'%(bname,bname,cname,x),'wb')
f.write(tuym.content)
print(cname,"第",x,"页保存完成")
x+=1
![在这里插入图片描述](https://img-blog.csdnimg.cn/4854421e04924a16b0242a606809cb39.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5pqX56Kz,size_20,color_FFFFFF,t_70,g_se,x_16)