爬虫 爬猫猫图片(牢饭吃到饱)
每天一个入狱小技巧
综合练习
打开这个网址
import requests import re import time
url = "http://www.ichong123.com/maomao"
headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36" }
paqv = requests.get( url=url, headers=headers )
paqv.encoding = 'utf-8'
sdq1 = re.compile(r'<div class="pet_s">.*?<img src=(?P<mao>.*?)width',re.S) paq = sdq1.finditer(paqv.text) a = 1
for it in paq: time.sleep(3) ul = it.group('mao') ul2 = eval(ul) sdz = requests.get(ul2)
with open(f"E:/百度文档/mao/{a}.jpg","wb") as f: f.write(sdz.content) f.close() a+=1 print("猫猫下载完了")
|
作者: 我叫史迪奇
本文来自于:
https://sdq3.link/reptile-mao.html博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议