import urllib2 import re def lookfor(string, url): file = urllib2.urlopen(url) text = file.readlines() for line in text: if re.match("(.*)"+string+"(.*)", line): print line; else: print "Line doesn't contain requested string." file.close() done = False while (done == False): userstring = input("What string do you want to search for?"); userurl = input("What URL do you want to search for?"); print lookfor(userstring, userurl); finish = "null" while (finish != "Y" and finish != "N"): finish = raw_input("Are you finished? Y/N") if (finish == "Y"): done = True; elif (finish == "N"): done = False;