import requests
import re
url=‘https://list.jd.com/list.html?cat=9987,653,655‘
res=requests.get(url)
image_pat=‘<img width="220" height="220" data-img="1" .*="//(.*?)">‘
imagelist=re.findall(image_pat,res.text)
print(len(imagelist))
x=1
#保存图像
for i in imagelist:
image_url=‘http://‘+i
res=requests.get(image_url)
with open(‘job/‘+str(x)+‘.jpg‘,‘wb‘) as pic_object: #wb 表示用二进制保存文件
pic_object.write(res.content) #对于 非文本请求用res.content
x+=1
原文:https://www.cnblogs.com/tiankong-blue/p/11581513.html