Created
February 24, 2013 18:07
-
-
Save diffalot/5024859 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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