Reputation: 11
I am trying to make a script on Python that autofills a form on this website form using Mechanize. The script should be able to loop and create unlimited entries on the form since there is no Capatcha.
Although, I am fairly new to Python and Mechanize, I know the basics and know HTML fairly well but am still looking for help.
If any of you could help I would greatly appreciate it.
This is what I have so far...
import mechanize
#This bot allows for autofill on the ShoezGallery Raffle.
browser = mechanize.Browser()
response = br.open("http://yeezy.shoezgallery.com/")
br.addheaders = [("User-agent","Mozilla/5.0")]
url = "http://yeezy.shoezgallery.com/"
browser.select_form(nr=0)
browser.form['nom'] = Last name
browser.form['prenom'] = First Name
browser.form['mail'] = my email here
browser.form['telephone'] = phone number here
browser.form['taille'] = 4313
browser.form['pays'] = Etats_Unis
brower.submit()
response = browser.open('http://yeezy.shoezgallery.com/')
print response.read()
EDIT The code format change.
Upvotes: 1
Views: 8481
Reputation: 15533
Your code is doing last things first and you have mixed browser
and br
browser = mechanize.Browser()
response = br.open("http://yeezy.shoezgallery.com/")
should be
br = mechanize.Browser()
br.addheaders = [("User-agent","Mozilla/5.0")]
response = br.open(url)
Read pythonforbeginners.com/mechanize/python-mechanize-cheat-sheet and follow the example code on this site.
Upvotes: 2