欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

爬虫第二天--美女图片

程序员文章站 2022-05-15 18:38:06
...

Happy ~

#导入requets
import requests

url = "http://mm.chinasareview.com/wp-content/uploads/2017a/07/18/07.jpg"

headers = {
  "Host":"mm.chinasareview.com",
  "Connection":"keep-alive",
  "Cache-Control":"max-age=0",
  "Upgrade-Insecure-Requests":"1",
  "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64)    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
  "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
  "Accept-Encoding":"gzip, deflate",
  "Accept-Language":"zh-CN,zh;q=0.9",
  "Cookie":"__jsluid=14600d3c4078768577d30aceeb875172",
  "If-None-Match":"f67cd360b83ed31:108f",
  "If-Modified-Since":"Fri, 06 Oct 2017 15:32:54 GMT",
}
#get请求
response = requests.get(url,headers=headers)

print(response.status_code)
#保存图片
if response.status_code == 200:#200成功
    with open("logo.jpg",'wb') as f:
        f.write(response.content)


print("图片下载完成")

效果图:
爬虫第二天--美女图片

爬虫第二天--美女图片

相关标签: cookie