保存图片

import requests
import re

headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"X-Requested-With": "XMLHttpRequest",
"Host": "tq.365taoquan.cn",
"Cookie": "JSESSIONID=14B5326E4081413C9BD7C4BC002A53FA",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.5(0x17000523) NetType/WIFI Language/zh_CN",
"Referer": "http://tq.365taoquan.cn/seller/classify?agentId=-1&inviteBuyerId=-1&shareBuyerId=0&wxCode=365TQ",
"Connection": "keep-alive"
}
url = 'http://tq.365taoquan.cn/seller/classify?agentId=-1&inviteBuyerId=-1&shareBuyerId=0&wxCode=365TQ'

r = requests.get(url, headers=headers)
# print(r.text)
pic_url = re.findall(r'img class="product-img" src="(http.*?)"', r.text)
res = re.findall((r'<p>(.*?)</p>'), r.text)
print(res)
print(pic_url)
j = 5
for i in pic_url:
p = requests.get(i)
with open("E:\\图片logo\\%s.jpg" % res[j], 'wb') as jpg:
j += 1
jpg.write(p.content)

posted on 2019-09-02 10:32  WapN  阅读(361)  评论(0编辑  收藏  举报

导航