V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  harvies  ›  全部回复第 3 页 / 共 3 页
回复总数  49
1  2  3  
2019-05-21 23:34:03 +08:00
回复了 onecode 创建的主题 Python 技术渣,谁给写个爬虫,感谢
import json
import os

import requests

if __name__ == '__main__':
flag = True
page = 1
while flag:
print("page:" + str(page))
list_html = requests.get("http://adr.meizitu.net/wp-json/wp/v2/posts?page=" + str(page) + "&per_page=20")
content = list_html.content
json_loads = json.loads(content)
if isinstance(json_loads, list):
print(json_loads)
for list_item in json_loads:
id_ = list_item['id']
title = list_item['title']
print(title)
detail_html = requests.get("http://adr.meizitu.net/wp-json/wp/v2/i?id=" + str(id_))
detail_json = json.loads(detail_html.content)
print(detail_json)
str_content_ = detail_json['content']
content__split = str_content_.split(',')
print('downloading ' + str(content__split))
for detail_item in content__split:
print(detail_item)
rfind = detail_item.rfind('/')
file_name = detail_item[rfind + 1:len(detail_item)]
folder_path = "./images/" + title + '/'
if not os.path.exists(folder_path):
os.makedirs(folder_path)
requests_get = requests.get(detail_item)
with open(folder_path + file_name, "wb") as f:
f.write(requests_get.content)
else:
code_ = json_loads['code']
if code_ != 'rest_post_invalid_page_number':
print(code_)
else:
print(code_ + " exit")
flag = False
page += 1
2019-03-03 18:56:44 +08:00
回复了 VoidChen 创建的主题 问与答 求教最好的 Linux 日常使用方案
manjaro 也可以(archlinux 衍生版),用过好多 linux 发行版,最后还是选择 arch 了, https://i.imgur.com/7NPX24W.png
2019-03-03 18:51:57 +08:00
回复了 mfanming 创建的主题 新手求助 v2ex 怎么发图?
2019-03-03 18:43:47 +08:00
回复了 VoidChen 创建的主题 问与答 求教最好的 Linux 日常使用方案
上 archlinux 吧 qq 微信都正常使用(wine),不会发图片,上外链吧 https://s2.ax1x.com/2019/03/03/kLIv90.png
2019-03-03 18:37:16 +08:00
回复了 isCyan 创建的主题 V2EX 攻略:教你如何在 V2EX 发图片/插链接/插代码/插视频(第二版)
2018-10-23 17:56:35 +08:00
回复了 fox1955 创建的主题 问与答 那个 google 大数据的 3 万单词表,我添加了对应的中文解释
star 支持
2018-10-15 20:23:44 +08:00
回复了 hhhsuan 创建的主题 问与答 如何在国内使用抖音国际版版?
旧版,正在用
https://pan.baidu.com/s/1eTUE-qHXYFnJw-vkdhA-7g 密码:qwer,拿走,不谢
2018-10-04 12:03:41 +08:00
回复了 dante1029 创建的主题 推广 明天女儿生日,盖楼送 5 件 T 恤。
生快
1  2  3  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5626 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms · UTC 06:37 · PVG 14:37 · LAX 23:37 · JFK 02:37
Developed with CodeLauncher
♥ Do have faith in what you're doing.