python 自定义get post请求

python 自定义get post请求


import requests     //导入一个requests 三方库
url = 'https://www.zbjuran.com/uploads/20190507/bf2msnwczab936.jpg'   //定义一个URL地址
response = requests.get(url)  //使用response语句来接收requests获取的geturl内容
print(response.headers)  //打印输出请求头部分
print(response.status_code) //打印输出请求状态码

with open("zbjuran.jpg","wb")as f:
   f.write(response.content)      //with来打开读取的URL图片并写到本地,并获取response的数据信息


QQ截图20190509200251.jpg


{'Server': 'nginx', 'Date': 'Thu, 09 May 2019 11:59:34 GMT', 'Content-Type': 'image/jpeg', 'Content-Length': '120739', 'Last-Modified': 'Tue, 07 May 2019 02:24:32 GMT', 'Connection': 'keep-alive', 'ETag': '"5cd0ec60-1d7a3"', 'Expires': 'Sat, 08 Jun 2019 11:59:34 GMT', 'Cache-Control': 'max-age=2592000', 'Accept-Ranges': 'bytes'}
200