因发帖规则,如需爬取其他各大网站请详细看我发布的文章
本代码仅供教学使用,任何非法行为与本帖无关
超级规范的代码 —— 供大家免费使用、教学(云展365)
import ast
import os
import requests
import json
import demjson
def get_html(url):
response = requests.get(url)
return response.content
def paqu(path):
global imagedata
k = 1
if not os.path.isdir(path):
os.makedirs(path)
pic_urls = []
url = 'https://book.yunzhan365.com/bdgb/acsf/mobile/javascript/config.js?GgcZj7XFqw1/8OXdk4csQQ=='
content = get_html(url)
text = str(content).replace('var htmlConfig = ', '', 1)
text1 = text.replace(';', '', 1)
# json_object = ast.literal_eval(text)
print(type(text1))
date = eval(text1)
datejson = json.loads(date)
print(type(datejson))
print(datejson['fliphtml5_pages'])
for j in range(len(datejson["fliphtml5_pages"])):
imagedata = datejson['fliphtml5_pages'][j]['n'][0]
pic_urls.append('https://book.yunzhan365.com/bdgb/acsf/files/large/' + imagedata)
print(pic_urls)
for l in range(len(pic_urls)):
print("正在下载小黄图* " + str(k))
try:
imagedata = get_html(pic_urls[l])
except:
print("下载失败")
k = k - 1
with open(path + '/' + str(k) + ".jpg", "wb") as f:
f.write(imagedata)
k = k + 1
print("下载完毕")
if __name__ == '__main__':
paqu('yunzhan365')
使用效果图
还有什么问题可在评论区提问