Skip to content

Instantly share code, notes, and snippets.

@whiteclover
Created July 1, 2013 00:06
Show Gist options
  • Save whiteclover/5897574 to your computer and use it in GitHub Desktop.
Save whiteclover/5897574 to your computer and use it in GitHub Desktop.
get form from web page
import mechanize
import sys
br = mechanize.Browser()
response = br.open(sys.argv[1])
for form in br.forms():
print "name:[%r] id:[%r] action:[%s]" %(form.name, form.attrs.get('id'), form.action)
print "Controls: "
for control in form.controls:
print ' ', control.type, control.name, repr(control.value)
print(" ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment