批量获取百度贴吧娱乐明星的照片

import requests
import re

url='http://tieba.baidu.com/photo/g/bw/picture/list?kw=%E6%9D%A8%E6%B4%8B&alt=jview&rn=200&tid=4748284434&pn=1&ps=1&pe=40&info=1&_=1569421785713'
res=requests.get(url)
pat='"murl":"(.*?)"'
rst=re.findall(pat,res.text)
for i in rst:

x=re.findall('(http://+[\S]+?.jpg)',i)
# print(x)
res=requests.get(x[0])
y=re.findall('[a-zA-Z0-9]+?.jpg',x[0])[0]
# print(y)

with open('job/'+y,'wb') as pic_object:
pic_object.write(res.content)

猜你喜欢

转载自www.cnblogs.com/tiankong-blue/p/11588245.html