网络编程
位置:首页>> 网络编程>> Python编程>> 在python中使用requests 模拟浏览器发送请求数据的方法

在python中使用requests 模拟浏览器发送请求数据的方法

作者:hotProgramming  发布时间:2022-05-05 03:17:35 

标签:python,requests,请求

如下所示:


import requests

url='http://####'
proxy={'http':'http://####:80'}
headers={
 "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
 "Accept-Encoding": "gzip, deflate, br",
 "Accept-Language": "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3",
 "Connection":"keep-alive",
 "Host":  "36kr.com/newsflashes",
 "Upgrade-Insecure-Requests":"1",
 "User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:55.0) Gecko/20100101 Firefox/55.0"
}
respone=requests.get(url,timeout=10,headers=headers,proxies=proxy)
print(respone.status_code)

来源:https://blog.csdn.net/phplaoniao/article/details/79039772

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com