I have recently been messing with form submission and I was making a Python script to see if I could create Steam accounts through only entering the Captcha. For reference, the site I am submitting to is https://store.steampowered.com/join/. As shown by a mechanize request, the forms to fill are shown below:
<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)>>
Almost everything seems to work, but I’m having a little trouble getting mechanize and urllib2 to properly submit the form. I’m sure that I’m just doing something small and simple wrong, but I have spent a long time trying to find this error. My current request is formulated in a few simple lines like so:
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)
Most of this request is probably right and there are only a few lines I really deem suspicious. With mechanize I am trying to check the “I agree AND am 13 years of age or older” box with the line self.form.find_control(id="i_agree_check").items[0].selected = True. Based on some of my testing I think that that line might actually work, but the whole setting of the ReadOnly challenge_question portion is most likely bugged. For reference, that code segment is:
control = self.form.find_control("challenge_question")
control.disabled = False
control.readonly = False
control.value = "NameOfSchool"
The final possibility for failure of submission would be the submission method: urllib2.urlopen(self.form.click()).read()
If anyone has ANY ideas about what could be going wrong or even an alternative method to accomplish the task using Python, I would be very grateful. I have searched hard and failed. If you can, lend a hand!
Fetch page
https://store.steampowered.com/join/and search for regexp<input type="hidden" id="captchagid" name="captchagid" value="(.+)">.Captcha URL will be
https://store.steampowered.com/public/captcha.php?gid=<gid>.Fetch
https://store.steampowered.com/join/createaccount/with POST data: