1 Star 0 Fork 0

耿直的小爬虫/Climb the bucket map

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
爬取斗图吧然后保存数据库(1).py 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
from pyquery import PyQuery as pq
import requests
from redis import StrictRedis
import os
print('windows直接复制链接会自动把\改为/的')
#dizhi=input('请输入你要保存的文件位置(如F:/......):')
#cu=dizhi.replace("\\",'/')
o=1
headers={
'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0'
}
def xpan(canshu):
try:
url = 'https://www.doutula.com/photo/list/?page=' + str(canshu)
sp = requests.get(url, headers=headers).text
doc=pq(sp)
item=doc('.col-xs-6 img').items()
for i in item:
cu=i.attr('data-original')
#r(cu,'F:/斗图的/%s.jpg'%u)
# u+=1
#print('当前已保存%d张'%u)
#print(cu)
redis = StrictRedis(host='172.18.200.5', port=6379, db=1, password='')
redis.sadd('斗图网全部的', cu)
except Exception as e:
print('出现错误',e.args)
print('请输入你要从第几页爬爬到第几页')
a=int(input('请输入你要从第几页开始爬:'))
b=int(input('请输入你要截止页数:'))
print('正在爬取链接并保存到redis数据库中请稍等........')
for i in range(a,b):
xpan(i+1)
print('ok了')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/testp2y/Climb-the-bucket-map.git
git@gitee.com:testp2y/Climb-the-bucket-map.git
testp2y
Climb-the-bucket-map
Climb the bucket map
master

搜索帮助