0

I have this code:

import mechanize
def register():
            br = mechanize.Browser()
            br.set_handle_robots(False)
            br.open("http://somtehing.com/form2/index.php")
            br.select_form(nr=0)
            br.form["email"] = "stone@klikni.com"
            br.form["name"] = "Jan"
            br.form["nickname"] = "Vrsrly"
            br.form["postnum"] = "41182"
            br.form["age"] = "52"
            br.form["sex"] = ["man"]
            br.form["tel"] = "+420723545054"
            br.find_control("rules").items[0].selected = True
            res = br.submit()
            content = res.read()
            with open("mechanize_results.html", "w") as f:
                f.write(content)

but when i look on the mechanize_results.html website, it is just a filled form, checkbox checked, but i do not know if it was sent. When I did it manually, it redirected me to a page where "Registered successfully" was written. And I am not getting this response with mechanize. Any ideas how to solve it?

Yerdno
  • 21
  • 1
  • 3

1 Answers1

0

I have just solved a similar problem in witch the form.submit seemed to have No effect

datat = {'username': 'lnIqd6Et','password':'4BafqzIm8sLgWxdvw9Cb'}
#Encode the parameters
data = urllib.urlencode(datat)
#Submit the form (POST request).
print "POST"
browser.open(post_url,data)
print "POSTED"
print browser.open(url_to_get).read()