python 爬虫斗图吧 多页图片
生活随笔
收集整理的這篇文章主要介紹了
python 爬虫斗图吧 多页图片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
代碼如下:
import requests import bs4 import osfor i in range(1,6):resp = requests.get(f"https://www.doutub.com/img_lists/miao/{i}")t = resp.textd = bs4.BeautifulSoup(t,"html.parser")all_images = d.select("img")#print(all_images)folder = f'./imgs/page{i}'if not os.path.exists(folder):os.makedirs(folder)for img in all_images:try:src_value = img["data-src"]src_name = img["alt"]type = src_value[-3:]resp1 = requests.get(src_value)with open(f'{folder}/{src_name}.{type}',"wb") as f:f.write(resp1.content)except KeyError:pass結果如下:
?????????
?
?
總結
以上是生活随笔為你收集整理的python 爬虫斗图吧 多页图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 鼠标手势软件MouseGesture v
- 下一篇: python instagram 爬虫