参考:井蛙不可语于海
一、需要注意的坑
在resquests中不用加上Content-Type,否则请求无法成功,它会有一个默认值。
二、代码示例
try:
url = "https://open.soft.360.cn/softpost.php?act=softadd"
# 请求头
headers = {
"Accept-Encoding": "gzip, deflate, br",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36",
"Cookie": "__huid=11ez8Bd5Ciocx",
"X-Requested-With": "XMLHttpRequest",
"Connection": "keep-alive",
"Accept-Language": "zh-CN,zh;q=0.9",
"Referer": "https://open.soft.360.cn/softsubmit.php"}
# 参数
files = {"name": (None, "血刀老祖"),
"version": (None, "2.0.0.0"),
"download": (None, "www.baidu.com"),
"stamp": (None, "1579228685"),
"token": (None, "bnvbdddjdjsjsajkkwawaw")
}
r = requests.post(url=url, files=files, headers=headers)
r_json = r.json()
print u"状态码", r.status_code
print json.dumps(r_json, encoding="utf-8", ensure_ascii=False)
except BaseException as e:
print u"360检测失败!", str(e)