手动配置请求头
试试 requests
headers={"Content-Type":"application/x-ndjson"}
你提交的参数按照 ndjson 格式拼接好就行了
response = requests.post(base_url, headers={"Content-Type":"application/x-ndjson"}, data=data.encode("utf-8"))
嗯,我把参数放在 data 里面的,也可行,多谢了。
url = 'https://192.168.1.1:8888/xxx'
headers = {
'content-type': 'application/x-ndjson',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36',
'kbn-version': '6.5.4'
}
with open('a.txt', mode='r+', encoding='utf8') as f:
data = f.read()
print(data)
res = requests.post(url, data=data.encode('utf8'), headers=headers, verify=False).content.decode('utf8')
print(res)