用Python提交表单

用Python提交表单,python,mechanize,Python,Mechanize,我最近一直在处理表单提交,我正在制作一个Python脚本,看看是否可以只通过输入验证码来创建Steam帐户。作为参考,我提交的网站是。如mechanize请求所示,要填写的表格如下所示: <create_account POST https://store.steampowered.com/join/ application/x-www-form-urlencoded <TextControl(accountname=)> <SelectControl(choose_ac

我最近一直在处理表单提交,我正在制作一个Python脚本,看看是否可以只通过输入验证码来创建Steam帐户。作为参考,我提交的网站是。如mechanize请求所示,要填写的表格如下所示:

<create_account POST https://store.steampowered.com/join/ application/x-www-form-urlencoded
<TextControl(accountname=)>
<SelectControl(choose_accountname=[*, , ])>
<PasswordControl(password=)>
<PasswordControl(reenter_password=)>
<TextControl(email=)>
<TextControl(reenter_email=)>
<HiddenControl(challenge_question=) (readonly)>
<TextControl(secret_answer=)>
<HiddenControl(captchagid=1009037421128850761) (readonly)>
<TextControl(captcha_text=)>
<HiddenControl(action=submit_agreement) (readonly)>
<CheckboxControl(i_agree_check=[on])>
<HiddenControl(ticket=) (readonly)>>
这个请求大部分可能是正确的,我认为只有几行是可疑的。使用
mechanize
我正在尝试用行
self.form.find\u control(id=“I\u agree\u check”).项[0]检查“我同意并且13岁或以上”框。选中=True
。根据我的一些测试,我认为这一行实际上可能有效,但ReadOnly
challenge\u question
部分的整个设置很可能存在漏洞。作为参考,该代码段为:

    control = self.form.find_control("challenge_question")
    control.disabled = False
    control.readonly = False
    control.value = "NameOfSchool"
提交失败的最后一种可能性是提交方法:
urllib2.urlopen(self.form.click()).read()


如果有人对可能出现的错误有任何想法,或者甚至有其他方法可以使用Python完成任务,我将非常感激。我努力寻找,但失败了。如果可以,请伸出援手

获取页面
https://store.steampowered.com/join/
并搜索regexp

验证码URL将为
https://store.steampowered.com/public/captcha.php?gid=

获取
https://store.steampowered.com/join/createaccount/
带有POST数据:

    accountname=<name>&password=<password>&email=<email>&challenge_question=<question>&secret_answer=<secretansewer>&captchagid=<gid>captcha_text=<captch_text>&i_agree=1&ticket=&count=4
accountname=&password=&email=&challenge\u question=&secret\u answer=&captchagid=captcha\u text=&i\u agree=1&ticket=&count=4

每次使用&count=4真的有效吗?那么我该如何提交这样一个POST请求呢?@Paul urllib.urlopen(url,POST_data)我通过一点搜索发现了这一点。显然,如果你不重复使用CAPTCHA,计数并不重要。一切都好!非常感谢。
    accountname=<name>&password=<password>&email=<email>&challenge_question=<question>&secret_answer=<secretansewer>&captchagid=<gid>captcha_text=<captch_text>&i_agree=1&ticket=&count=4