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

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

程序员文章站 2022-11-01 21:11:19
如下所示: import requests url='http://####' proxy={'http':'http://####:80'} head...

如下所示:

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)

以上这篇在python中使用requests 模拟浏览器发送请求数据的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。