【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)
标签:douban,headers,Python,Request,Headers,Sec,sec,com,Fetch 来源: https://www.cnblogs.com/hkwJsxl/p/16480273.html