【问题标题】:Using requests to post data to an html form使用请求将数据发布到 html 表单
【发布时间】:2012-07-15 21:00:41
【问题描述】:

我希望使用 python 将数据发布到网站表单。 该网站是http://up-to-no-good.appspot.com 我知道我需要使用 post,但我不知道如何让它实际发布。 我想发送的示例输入(使用请求模块)是:

map     : arena_lumberyard at: 0 x, 0 y, 0 z

players : 21 (33 max)

# userid name uniqueid connected ping loss state # 88 "gza" STEAM_0:0:31273869 30:33 70 0 active # 75 "MasterDovahBeard" STEAM_0:1:41046299 46:08 120 0 active # 101 "Gigs" STEAM_0:0:17483483 04:40 78 0 active

【问题讨论】:

    标签: python html post input python-requests


    【解决方案1】:

    使用mechanize。该模块自动执行网页导航、表单、按钮等。

    【讨论】:

    • 非常感谢。如果我可以让它工作,我会稍后发布。谢谢!
    【解决方案2】:

    这里是一个例子:requests doc - POST request

    您需要使用键/值数据创建一个字典并将其传递给requests.post()

    POST_DATA = {'user_id': 88
                ,'name'   : "gza"
                # ...
                }
    content = requests.post('http://example.com/', data=POST_DATA).content
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-14
      • 1970-01-01
      相关资源
      最近更新 更多