python爬取百度贴吧图片

这次爬虫使用python3爬取

我没需要引入lxml库:

python爬取百度贴吧图片

创建爬取页面的函数爬取贴吧列表,通过lxml获取到每个帖子的链接地址fulllink

python爬取百度贴吧图片

通过上面函数获取的帖子详细地址,访问每个帖子的详情页面,获取img的src

python爬取百度贴吧图片

拿到img的下载地址进行下载:

python爬取百度贴吧图片

创建测试调度器:
python爬取百度贴吧图片

python爬取百度贴吧图片

测试结果:

python爬取百度贴吧图片

python爬取百度贴吧图片

下完成!

刚刚学习请多指教:上一篇介绍的是从百度贴吧读取信息:https://blog.csdn.net/qq_35723619/article/details/83275683