oldj 大佬有话说 :
写了个漫画下载的脚本
接https://www.hostloc.com/thread-674260-1-1.html
因为看老哥一直没发出来,所以就写了一个脚本下载
支持多线程下载
注意使用前修改json_url为json地址
脚本下载地址
https://github.com/tusik/json-parser-downloader/blob/master/process.py
https://raw.githubusercontent.com/tusik/json-parser-downloader/master/process.py
如果出现创建目录的编码报错,请注意设置环境编码为utf8
# -*- coding: UTF-8 -*-
import psycopg2
import requests
import sys,json,os
from threading import Thread
def download_img(path,url):
r = requests.get(url, headers=headers)
filename_t = str(url).split(‘/’)
filename = filename_t
with open(path+’/’+filename, ‘wb’) as f:
f.write(r.content)
headers = {
‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) ‘
‘Chrome/80.0.3987.149 Safari/537.36 ‘
}
title = ”
json_url = ”
if not os.path.exists("export.json"):
r = requests.get(json_url, stream=True)
f = open("export.json", "wb")
for chunk in r.iter_content(chunk_size=512):
if chunk:
f.write(chunk)
with open("export.json","r",encoding=’utf-8′) as data:
json_obj = json.load(data)
for i in json_obj:
title = i[‘title’]
if not os.path.exists(title):
os.mkdir(title)
r = requests.get(i[‘cover’], headers=headers)
with open(i[‘title’]+"/cover.jpg", ‘wb’) as f:
f.write(r.content)
chaper = ”
for k in i[‘chapters’]:
threads = []
cp_title = k[‘title’]
if not os.path.exists(title+’/’+cp_title):
os.mkdir(title+’/’+cp_title)
print(‘Downloading ‘ + cp_title)
for j in k[‘images’]:
t = Thread(target=download_img,args=)
t.start()
threads.append(t)
for t in threads:
t.join()
b66667777 大佬有话说 :
感谢分享
C大 大佬有话说 :
谢谢!
夏渔 大佬有话说 :
感谢分享