jeudi 5 février 2015

Using Python to enter data into form and get data from results page

I am using Python 2.7 on a 32 bit Windows machine.


I am trying to enter species data into http://ift.tt/1id6z7Z and retrieve the results, but am having difficulty understanding how to do it. Needless to say I am relatively new to Python.


I have the following code:



import mechanize
import requests
import os, sys

br = mechanize.Browser()
br.open("http://ift.tt/1id6z7Z")

#List the forms
for form in br.forms():
print "Form name:", form.name
print form

br.form = list(br.forms())[0] # use when form is unnamed


At this point, I am unsure how to input data into br.form and save the output as an html page, which I would like to do.


The work flow is a little more complicated, because the second page needs a certain choice to be made that will get me to a species description, but I thought I would take it one step at a time.


Needless to say, I am new to Python





Aucun commentaire:

Enregistrer un commentaire