Question: This code is implemented and working, I just need someone to comment it out to explain what each part of the code is doing. The
I just need the top picture commented out more clearly and any variable name change suggestions or code restructuring recommendations are appreciated. (i.e to avoid using the break) . The code works, I just want it as readable and efficient as possible. Thanks. Good reviews for anyone who does this well! H JES-finalproject2 py Fde Edit Watcher MediaTools JES Functions Window Layout Help ng function from abore to make it search # I want to modify the Horspoolatchi # a webpage for a given string and to create an output file that # contains # searched string and higlight the searched string in some manner. each occurrence in context (50 characters before and after the Python provides modules to support access to the Internet without all the overhead of a browser. Basically, you can write small programs that are clients Python module urllib allows you to open URLS and read them as if they were filea As an example, we can access the news Web site http://www.cnn.com and dispay s " 00 the first 100 characters of the Web page that gets returned...by doing the following import urllib connect urllib.urlopen ("http://www.cnn.com" 01|: >>> news=connect.read() connect.close ) snews [0:100] 10 import urllib " def HorspoolMatching2 (string, webpageURL) result result beg#0 = urllib.urlopen (webpageUR.) = result.read() try: while (True): i, j # Horspoo!Matching (string, result[beg:)) if ins-1: break isbegt conte beg itlen (string) -1 resliat.append (context) xt- resultti-51;i]+" result(i;i+len (string,1+"+result[i+1en(stringhi.ien (string)+ except IndexEETOrt print "done i return renlist
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
