python 语法介绍
import requestsimport json
import time
headers= {"Accept": "*/*",
"Accept-Encoding": "br, gzip, deflate",
"Accept-Language": "zh-cn",
"Connection": "keep-alive",
"Content-Type": "application/json",
"Host": "api9.tianyancha.com",
"Referer": "https://servicewechat.com/wx9f2867fc22873452/27/page-frame.html",
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.3(0x17000321) NetType/WIFI Language/zh_CN",
"version": "TYC-XCX-WX"
}
target_url = "https://api9.tianyancha.com/services/v3/search/sNorV4/%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4?pageSize=10&sortType=0&pageNum=1"
headers['"Authorization'] = "###oo34J0QiGC9pbqe_nLrAXQDxMAgM###{}###72f0e8be443b386a6c56589799bdbd3c".format(round(time.time()*1000))
res=requests.get(target_url,headers=headers)
print(res.text)
这个打印的返回:
{"data":null,"message":"请先登陆再试试","state":"warn","special":"mustlogin"}
我爬微信小程序的天眼查的搜索页面是这样的,请问这是为啥?这个里面有个认证
authentication ,我看是不变的直接传输过去
回答:
请把:headers['"Authorization'] 改成 headers['Authorization']
以上是 python 语法介绍 的全部内容, 来源链接: utcz.com/a/157601.html