首页 > 编程知识 正文

爬虫 表情包,“爬”表情包

时间:2023-05-04 17:41:16 阅读:280535 作者:1550

本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理

以下文章来源于腾讯云 作者:python学习教程

( 想要学习Python?Python学习交流群:1039649593,满足你的需求,资料都已经上传群文件流,可以自行下载!还有海量最新2020python学习资料。 )

前言

Python现在非常火,语法简单而且功能强大,很多同学都想学Python!所以小的给各位看官们准备了高价值Python学习视频教程及相关电子版书籍,欢迎前来领取!

python爬虫教程:《利用Python爬取表情包》,微信没有表情包?不用愁!老师带领你使用多线程爬虫一键爬取20w的表情包~

项目源码: from pyquery import PyQuery as pqimport requestsfrom redis import StrictRediso=0headers={ '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('斗图网下载图片的URL', cu) except Exception as e: print('出现错误',e.args)a=int(input('请问你需要爬取多少页呢:'))print('正在爬取链接并保存到redis数据库中请稍等........')for i in range(a): xpan(i+1)redis = StrictRedis(host='172.18.200.5', port=6379, db=1, password='')redis.srem('斗图网下载图片的URL','None')for i in redis.smembers('斗图网下载图片的URL'): t=str(i,encoding='utf8') #print(t) r=t.split('/')[-1] dizhi='F:/斗图/'+r req=requests.get(t) with open(dizhi,'wb')as p: p.write(req.content) print('保存完毕 已保存了%d张'%o) o+=1

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。