Python form submission

I recently fiddled with submitting a form and I was doing a Python script to find out if I can only create Steam accounts through Captcha input. For reference, the site I'm posting to is https://store.steampowered.com/join/ . As shown in the mechanization request, the filling forms 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 have slight problems with mechanization and urllib2 to submit the form correctly. I am sure that I am just doing something small and simple, but I have been trying for a long time to find this error. My current request is formulated in a few simple lines:

 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 query is probably correct, and there are only a few lines that I really consider suspicious. Using mechanize I try to check the "I agree, I am 13 years old and older" self.form.find_control(id="i_agree_check").items[0].selected = True with the line self.form.find_control(id="i_agree_check").items[0].selected = True . Based on some of my tests, I think this line might work, but all the settings in the ReadOnly challenge_question part are most likely tapped. For reference, this code segment:

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

The last opportunity to refuse a view will be the submit method: urllib2.urlopen(self.form.click()).read()

If anyone has ANY ideas on what might be the wrong or even alternative method for doing the task using Python, I would really appreciate it. I searched a lot and failed. If you can, reach out!

+4
source share
1 answer

Extract the page https://store.steampowered.com/join/ and search for regexp <input type="hidden" id="captchagid" name="captchagid" value="(.+)"> .

The Captcha URL will be https://store.steampowered.com/public/captcha.php?gid=<gid> .

Extract https://store.steampowered.com/join/createaccount/ with POST data:

  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
source

Source: https://habr.com/ru/post/1388217/


All Articles