2011-12-27 14 views
4

私は最近、フォームの提出を乱しているし、私はCaptchaを入力するだけでスチームアカウントを作成できるかどうかを確認するPythonスクリプトを作っていた。参考までに、私が提出するサイトはhttps://store.steampowered.com/join/です。フォーム提出のPython

<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)>> 

は、ほとんどすべてが動作しているようですが、私は適切にフォームを送信するために機械化とurllib2の取得少し問題を抱えている:Mechanizeの要求によって示されているように、記入するフォームを以下に示します。私はちょっとしたことをやっていると確信していますが、私はこのエラーを見つけるのに長い時間を費やしてきました。私の現在のリクエストがそうのようないくつかのシンプルなラインで処方されています

def submit_form(self, captcha_text): 
    self.form["accountname"]=account_prefix+get_next_number() 
    self.form["password"]=account_password 
    self.form["reenter_password"]=account_password 
    email = emails.pop() 
    self.form["email"] = email 
    self.form["reenter_email"] = email 
    control = self.form.find_control("challenge_question") 
    control.disabled = False 
    control.readonly = False 
    control.value = "NameOfSchool" 
    self.form["secret_answer"] = secret_answer 
    self.form["captcha_text"] = captcha_text 
    self.form.find_control(id="i_agree_check").items[0].selected = True 
    print urllib2.urlopen(self.form.click()).read() 
    inc_account_number() 
    resave_email_list(emails) 

この要求のほとんどは、おそらく権利であると私は本当に疑わしいと考えるだけで数行があります。 mechanizeと私は "私は同意し、13歳以上です"というボックスに、self.form.find_control(id="i_agree_check").items[0].selected = Trueという行をチェックしようとしています。私のテストのいくつかに基づいて、私はその行が実際にはうまくいくかもしれないと思うが、ReadOnly challenge_question部分の設定全体が盗聴されている可能性が最も高い。参考のために、そのコードセグメントは次のとおりです。

control = self.form.find_control("challenge_question") 
    control.disabled = False 
    control.readonly = False 
    control.value = "NameOfSchool" 

提出の故障のための最終的な可能性が提出方法次のようになります。誰でもANY間違って行くことができるかについてのアイデア、あるいは代替を持っている場合urllib2.urlopen(self.form.click()).read()

メソッドは、Pythonを使用してタスクを達成するために、私は非常に感謝します。私は捜索して失敗しました。あなたができるなら、手を貸してください!

答えて

0

フェッチページhttps://store.steampowered.com/join/とregexp <input type="hidden" id="captchagid" name="captchagid" value="(.+)">を検索してください。

キャプチャのURLはhttps://store.steampowered.com/public/captcha.php?gid=<gid>になります。

POSTデータでhttps://store.steampowered.com/join/createaccount/を取得:

accountname=<name>&password=<password>&email=<email>&challenge_question=<question>&secret_answer=<secretansewer>&captchagid=<gid>captcha_text=<captch_text>&i_agree=1&ticket=&count=4 
+0

それは実際に動作します&4 =すべての時間をカウント?そのようなPOST要求を提出するにはどうすればよいですか? – Paul

+0

@Paul urllib.urlopen(url、post_data) –

+0

私はそれを少し調べて考え出しました。あなたがcaptchaを再利用していない場合、明らかにカウントは重要ではありません。すべてが良いです!バンドルありがとう。 – Paul