canwex 最近的时间轴更新
canwex

canwex

V2EX 第 414331 号会员,加入于 2019-05-21 15:15:41 +08:00
canwex 最近回复了
2019-05-21 21:41:57 +08:00
回复了 onecode 创建的主题 Python 技术渣,谁给写个爬虫,感谢
import requests
import json

url = 'https://adr.meizitu.net/wp-json/wp/v2/posts?page={}&per_page={}'
per_page = 100
page = 52

print('##### spider start #####')
while True:
page += 1
json_data = requests.get(url.format(page, per_page))
data = json.loads(json_data.text)

if not isinstance(data, list):
print('##### spider end #####')
break

for item in data:
thumb_src = item['thumb_src']
title = item['title'] + '.jpg'
print('[+] downloading {} ...'.format(title))
meizi = requests.get(thumb_src)
if meizi.status_code == 200:
with open(title, 'wb') as f:
f.write(meizi.content)
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2838 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 09:25 · PVG 17:25 · LAX 01:25 · JFK 04:25
Developed with CodeLauncher
♥ Do have faith in what you're doing.