Python post请求复选框和提交

2024-09-30 08:35:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我想勾选一个复选框,然后通过Python提交表单。我不知道怎么解决。 HTML部分:

复选框:

 <input  type="checkbox" value="17213463" class="vehicle_checkbox" id="vehicle_checkbox_17213463" name="vehicle_ids[]"

              fms="2"
              id="vehicle_checkbox_17213463"
              class="vehicle_checkbox"
              building_id="4537773"
              custom_="1"
              tractive_random="0"
              ignore_aao="0"
              vehicle_type_ignore_default_aao="0"
              tractive_vehicle_id="0"
              tractive_building_random="0"
              trailer_vehicle_id="0"
              fire="1"
              wasser_amount="2000"
              lf_only="1"
              possible_tractive="[]"

          >

提交:

          <input class="btn btn-success  " id="alert_btn" name="commit" type="submit" value="Alarmieren" />

到目前为止,我尝试的是:

serviceurl = 'https://www.leitstellenspiel.de/missions/1502249226'
payload = {"17213463":"checked"}
r = s.post(serviceurl, data=payload,headers=headers)
print("Status code: ", r.status_code)
print("Printing Entire Post Request")
print(r.content)
   

但是我得到了一个404错误,尽管我可以通过s.get(thisURL)访问该网站。我搜索了很久,但没有找到正确的代码。有人能帮忙吗


Tags: nameidinputvaluetyperandomclass复选框

热门问题