本帖最后由 zyc183369 于 2020-6-6 17:24 编辑
[Python] 纯文本查看 复制代码 import urllib
import requests
import re
def picdown(m):
headers = {
'User - Agent': 'Mozilla / 5.0(Windows NT 6.1;WOW64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 78.0.3904.108 Safari / 537.36',
'Cookie':'__gads=ID=7bcdde2f7833c989:T=1591256329:S=ALNI_Mb0rB43nTRvuClCMnFdwTnUyG7iAA; UM_distinctid=1727e44b69b27f-02086d895f4aff-4e4c0f20-1fa400-1727e44b69e33c; PHPSESSID=q4tiusrjbdk84sjjavo2db93qf; CNZZDATA1260546685=1753245676-1591253670-https%253A%252F%252Fwww.baidu.com%252F%7C1591432820'
}
url = 'https://www.fabiaoqing.com/biaoqing/lists/page/%d.html' % m # 通过形参可以自定义页数
r = requests.get(url,headers = headers) # 获取url页面
r1 = r.text # 爬取界面数导入r1
r2 = re.findall('<div.*?<a.*?<img.*?data-original="(.*?)".*?</a>', r1, re.S)
for i in range(0, len(r2)):
print(i, r2[i])
cc = r2[i]
c1 = cc[-8:]
urllib.request.urlretrieve(cc, 'D:/python/表情包/%s' % c1)#这里自定义保存地址
print("第%d页第%d张图片下载成功"%(m,i))
for i in range(80, 180):
picdown(i)
|