Skip to content

Instantly share code, notes, and snippets.

@diffalot
Created February 24, 2013 18:07
Show Gist options
  • Save diffalot/5024859 to your computer and use it in GitHub Desktop.
Save diffalot/5024859 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import re
import mechanize
import sys
import string
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
terms = sys.argv
del terms[0]
search_string = "\"" + string.join(terms, "\"+\"") + "\""
print re.escape(search_string)
br = mechanize.Browser()
br.open("http://knowledge.kaltura.com")# + search_string)
# follow second link with element text matching regular expression
#response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1)
assert br.viewing_html()
print br.title()
print br.geturl()
for form in br.forms():
print form
# .links() optionally accepts the keyword args of .follow_/.find_link()
#for link in br.links():
# print link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment