Python 官方文档:入门教程 => 点击学习
import requests res = requests.get("Http://127.0.0.1:9092") print(res.status_code) # 200 print(res.url) # http://
import requests
res = requests.get("Http://127.0.0.1:9092")
print(res.status_code) # 200
print(res.url) # http://127.0.0.1:9092/
print(res.headers) # {'Content-Type': 'application/JSON; charset=utf-8', 'Content-Length': '10', 'Date': 'Sat, 22 Dec 2018 13:36:16 GMT', 'Connection': 'keep-alive'}
print(res.cookies) # <RequestsCookiejar[<Cookie cid=hello world for 127.0.0.1/>]>
print(res.text) # 8248154254
print(res.content) # b'8248154254' 写图片
print(res.cookies['cid']) # hello world
# 爬取 图片
r1 = requests.get('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1545496551516&di=8ed19596bc72aa87299ed7f234830128&imgtype=0&src=http%3A%2F%2Fimg5.duitang.com%2Fuploads%2Fitem%2F201107%2F31%2F20110731155631_htMcs.jpg')
b = r1.content
with open('hao.jpg','wb') as f:
f.write(b)
--结束END--
本文标题: python3中requests 常用r
本文链接: https://lsjlt.com/news/186061.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0