本帖最后由 Jack2002 于 2021-8-2 10:40 编辑
完整代码给你
[Python] 纯文本查看 复制代码 # -*- coding: utf-8 -*-
from requests import Session
def main(*args):
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN,zh;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Content-Type": "application/json;charset=UTF-8",
"Cookie": "acw_tc=2760824616278701141955252e5efe261c712f620559d43111857f7a992a32; shimo_sid=s%3A719080c6949540d6883a2274f4d2546b.pZAQ9XjAU%2B%2BMjRbWGx%2BFtYKtRkZ2ApBErKIQPgpHDTM; anonymousUser=-735830681; deviceId=browser-6713d9eb-86f7-fd82-8005-e0a01e7c1976; sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2217b0482ec841c9-006395e0267596-3e604809-1fa400-17b0482ec856bf%22%2C%22%24device_id%22%3A%2217b0482ec841c9-006395e0267596-3e604809-1fa400-17b0482ec856bf%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; sensorsdata2015session=%7B%7D; deviceId=svc-9e02bfa4-3244-40a8-98fd-156e37f27a7d; udid=df60f4c84d1a2280b492IOw8S0Pn8cWWtb",
"DNT": "1",
"Connection": "keep-alive",
"cache-control": "no-cache",
"pragma": "no-cache",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"origin": "https://shimo.im",
"Referer": "https://shimo.im/forms/3gDyHRvvVHxVQryy/fill"}
s = Session()
s.headers = headers
szUrl:str = "https://shimo.im/forms/3gDyHRvvVHxVQryy/fill"
s.get(szUrl)
data:dict = {"formRev":1,
"userFinger":"-1",
"userName":"",
"duration":29,
"responseContent":[{"type":9,"guid":"AruMTHYd","text":{"content":"123"}},{"type":0,"guid":"d1kmXOF5","text":{"content":"456"}},{"type":4,"guid":"Y74tOmyW","text":{"content":"789"}}]}
s.headers["content-length"] = str(len(str(data)))
szUrl:str = "https://shimo.im/api/newforms/forms/3gDyHRvvVHxVQryy/submit"
res = s.post(szUrl, json=data)
print("status_code:", res.status_code)
main()
运行结果:返回状态码204,跟浏览器返回结果一致。
|