1.3 Create a form that asks the user to submit a URL and a search term. Write a CGI script that opens the URL and displays all the lines that contain the search term. #!/usr/bin/env python # import urllib import sys import re ###################### CGI header ########################## import cgi print "Content-Type: text/html\n" form = cgi.FieldStorage() ## add a form.getvalue for each of the names in your form: ## url = form.getvalue("url") searchterm = form.getvalue("searchterm") ########## start of HTML code ############################## print """ Search

Search results:

""" ######### open URL ######################################### try: remote = urllib.urlopen(url) except: print "cannot open URL" sys.exit() content = remote.readlines() keyword = re.compile(searchterm) for eachline in content: if keyword.search(eachline): print eachline ########### HTML footer ########################### print """ """