dimanche 19 avril 2015

Python mechanize - submit form response

I have this code:



import mechanize
def register():
br = mechanize.Browser()
br.set_handle_robots(False)
br.open("http://ift.tt/1H3gGOm")
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?


Aucun commentaire:

Enregistrer un commentaire