【Python爬虫技巧】快速格式化请求头Request Headers


from lxpy import copy_headers_dict
import requests

headers = """
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Cookie: ll="118091"; bid=XFRsLwrz81M; push_noty_num=0; push_doumail_num=0; dbcl2="249449316:gjeVE/jJwlY"; ct=y; ck=_VCi; ap_v=0,6.0
Host: movie.douban.com
Pragma: no-cache
Referer: https://www.douban.com/
sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-site
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
"""
headers = copy_headers_dict(headers)
pprint.pprint(headers)
res = requests.get(url='https://movie.douban.com/', headers=headers)
print(res.text)

【Python爬虫技巧】快速格式化请求头Request Headers

 

原创文章,作者:Carrie001128,如若转载,请注明出处:https://blog.ytso.com/274498.html

(0)
上一篇 2022年7月15日
下一篇 2022年7月15日

相关推荐

发表回复

登录后才能评论