requests 模块的用法
pic_res = requests.get(url, cookies=cookies, headers=headers)
with open('tmp.jpg', 'wb') as file:
file.write(pic_res.content)
Scrapy 框架 request 用法
def start_requests(self):
yield Request(url, cookies=cookies, headers=headers, callback=self.save_pic)
def save_pic(self, response):
with open('tmp.jpg', 'wb') as file:
file.write(response.body)