FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

dmzj · jackcoolpython/python-spider@9dbbffe · GitHub

Repository navigation

Commit 9dbbffe

Browse files
committed
dmzj
1 parent e20885e commit 9dbbffe

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

‎2020/dmzj/cartoon.py‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,30 @@
4545
chapter_save_dir = os.path.join(save_dir, name)
4646
if name not in os.listdir(save_dir):
4747
os.mkdir(chapter_save_dir)
48-
r = requests.get(url = url)
49-
html = BeautifulSoup(r.text, 'lxml')
50-
script_info = html.script
51-
pics = re.findall('\d{13,14}', str(script_info))
52-
for j, pic in enumerate(pics):
53-
if len(pic) == 13:
54-
pics[j] = pic + '0'
55-
pics = sorted(pics, key=lambda x:int(x))
56-
chapterpic_hou = re.findall('\|(\d{5})\|', str(script_info))[0]
57-
chapterpic_qian = re.findall('\|(\d{4})\|', str(script_info))[0]
58-
for idx, pic in enumerate(pics):
59-
if pic[-1] == '0':
60-
url = 'https://images.dmzj.com/img/chapterpic/' + chapterpic_qian + '/' + chapterpic_hou + '/' + pic[:-1] + '.jpg'
48+
r = requests.get(url = url)
49+
html = BeautifulSoup(r.text, 'lxml')
50+
script_info = html.script
51+
pics = re.findall('\d{13,14}', str(script_info))
52+
for j, pic in enumerate(pics):
53+
if len(pic) == 13:
54+
pics[j] = pic + '0'
55+
pics = sorted(pics, key=lambda x:int(x))
56+
chapterpic_hou = re.findall('\|(\d{5})\|', str(script_info))[0]
57+
chapterpic_qian = re.findall('\|(\d{4})\|', str(script_info))[0]
58+
for idx, pic in enumerate(pics):
59+
if pic[-1] == '0':
60+
url = 'https://images.dmzj.com/img/chapterpic/' + chapterpic_qian + '/' + chapterpic_hou + '/' + pic[:-1] + '.jpg'
61+
else:
62+
url = 'https://images.dmzj.com/img/chapterpic/' + chapterpic_qian + '/' + chapterpic_hou + '/' + pic + '.jpg'
63+
pic_name = '%03d.jpg' % (idx + 1)
64+
pic_save_path = os.path.join(chapter_save_dir, pic_name)
65+
with closing(requests.get(url, headers = download_header, stream = True)) as response:
66+
chunk_size = 1024
67+
content_size = int(response.headers['content-length'])
68+
if response.status_code == 200:
69+
with open(pic_save_path, "wb") as file:
70+
for data in response.iter_content(chunk_size=chunk_size):
71+
file.write(data)
6172
else:
62-
url = 'https://images.dmzj.com/img/chapterpic/' + chapterpic_qian + '/' + chapterpic_hou + '/' + pic + '.jpg'
63-
pic_name = '%03d.jpg' % (idx + 1)
64-
pic_save_path = os.path.join(chapter_save_dir, pic_name)
65-
with closing(requests.get(url, headers = download_header, stream = True)) as response:
66-
chunk_size = 1024
67-
content_size = int(response.headers['content-length'])
68-
if response.status_code == 200:
69-
with open(pic_save_path, "wb") as file:
70-
for data in response.iter_content(chunk_size=chunk_size):
71-
file.write(data)
72-
else:
73-
print('链接异常')
74-
time.sleep(10)
73+
print('链接异常')
74+
time.sleep(10)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL