【问题标题】:Python post request check checkbox and submitPython 发布请求检查复选框并提交
【发布时间】:2021-10-30 01:31:57
【问题描述】:

我想勾选一个复选框,然后通过 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) 访问该网站。我用谷歌搜索了很久,但没有找到正确的代码。有人可以帮忙吗?

【问题讨论】:

  • 你看过像 Flask 这样的 Python Web 框架吗?
  • @KrishnanShankar Flask 用于托管服务器服务,我认为这不是 OP 需要的
  • 是的,没关系。
  • 你能提供一个minimal working example吗?你能说明你正在使用什么包吗?

标签: javascript python php html request


【解决方案1】:

试试这个:

from requests_html import HTMLSession

s = HTMLSession()

serviceurl = 'https://www.leitstellenspiel.de/missions/1502249226'

payload = {"user_remember_me":"1"}

r = s.get(serviceurl, data=payload)

print("Status code: ", r.status_code)

print("Printing Entire Post Request")

print(r.content)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-13
  • 2020-01-14
  • 1970-01-01
  • 2016-10-18
  • 1970-01-01
  • 2016-03-24
相关资源
最近更新 更多