当前位置:网站首页>爬取表情包
爬取表情包
2022-07-29 05:23:00 【赵颂@】
[发表情网](https://www.fabiaoqing.com/biaoqing/lists/page/1.html)
import requests,os
from lxml import etree
from fake_useragent import UserAgent
def crawl(url):
headers={
"User-Agent":UserAgent().chrome
}
#获取页面响应信息
page_text=requests.get(url,headers).text
#解析表情包的详情页url
tree=etree.HTML(page_text)
list_data=tree.xpath('//div[@class="ui segment imghover"]/div/a')
if not os.path.exists('表情包'):
os.mkdir('表情包')
for i in list_data:
detail_url='https://www.fabiaoqing.com'+i.xpath('./@href')[0]
# print(detail_url)
#对详情页面url发起请求,获取响应
detail_page_text=requests.get(detail_url,headers).text
tree=etree.HTML(detail_page_text)
#得到搞笑图片的地址,发起请求进行持久化存储
detail_list_data=tree.xpath('//div[@class="swiper-wrapper"]/div/img/@src')[0]
fp=detail_list_data.split('/')[-1]
with open('表情包/'+fp, 'wb') as fp:
fp.write(requests.get(detail_list_data).content)
print(fp,'下载完了!!!')
#调用
crawl('https://www.fabiaoqing.com/biaoqing/lists/page/1.html')
边栏推荐
猜你喜欢

【软件工程之美 - 专栏笔记】25 | 有哪些方法可以提高开发效率?

倾角传感器精度校准检测

基于AD9850的多功能信号发生器

八大排序-----------快速排序

华为云14天鸿蒙设备开发-Day5驱动子系统开发

【软件工程之美 - 专栏笔记】21 | 架构设计:普通程序员也能实现复杂系统?

【软件工程之美 - 专栏笔记】“一问一答”第3期 | 18个软件开发常见问题解决策略

STM32 printf问题总结 semihosting microLIB理解

Reading papers on false news detection (5): a semi supervised learning method for fake news detection in social media

TLE5012b+STM32F103C8T6(bluepill)读取角度数据
随机推荐
Torch. NN. Parameter() function understanding
智慧能源管理系统解决方案
STM32 printf问题总结 semihosting microLIB理解
Zero basics FPGA (5): counter of sequential logic circuit design (with introduction to breathing lamp experiment and simple combinational logic design)
兼容cc1101/cmt2300-DP4301 SUB-1G 无线收发芯片
2022春招——芯动科技FPGA开发岗笔试题(原题以及心得)
HAL学习笔记 - 7 定时器之高级定时器
噪音监测传感系统
Huawei cloud 14 day Hongmeng device development -day5 drive subsystem development
Transformer review + understanding
充电桩应用方案
新能源充电桩后台管理系统平台
基于51单片机的DAC0832波形发生器
arduino uno错误分析avrdude: stk500_recv(): programmer is not responding
从头安装MYSQL(MYSQL安装文档-解压版)
2022 spring move - core technology FPGA post technical aspects (one side experience)
基于F407ZGT6的WS2812B彩灯驱动
智能温度控制系统
八大排序-----------快速排序
HAL库学习笔记-10 HAL库外设驱动框架概述