Question: My main function does not work fully as intended. I believe I have most of the python code finished. Below the code are test cases

My main function does not work fully as intended. I believe I have most of the python code finished. Below the code are test cases that need to be fulfilled. ------------------------------ """ Implement a simple general purpose aggregator Usage: aggregator.py filename topic filename: input file that contains a list of the online sources (urls). topic: topic to be researched and reported on """  import urllib.request import urllib.error import re import sys # Enter your function definitions here def getfiletopic(): """  'Help on function getfiletopic in module __main__:  getfiletopic()  # Check for correct number of arguments  # 3 arguments: name, filename, topic  """  for arg in sys.argv: print("command line argument: %s" % arg ) if len(sys.argv) == 3: print("number of arguments %d" % len(sys.argv)) else: sys.exit("Error: Requires 3 arguments.") getfiletopic() def main(): """  Runs through url links in source and provides and output txt file  on matching case summaries with arguments  """   # read command line, filename, topic #read file, line by line # for each line, pull contents from web using urllib if len(sys.argv) != 3: print("Error: Invalid arguments") print("Usage:aggregator.py filename topic") file = open(sys.argv[1], "r") out = sys.argv[2] + "summary.txt" file1 = open(out, "w") for line in file: try: from urllib.request import urlopen response = urlopen(line) content = response.read() count = 0 for line1 in content: list = line1.split(">") list = list[1].split(" 0: # if match, write contents to file file1.write(line1 + " ") file1.write("------------------------ ") count = count + 1 file1.write(line1) file1.write("----------------------------------------- ") except Exception as e: file1.write(str(e)) if __name__ == '__main__': main()

----------------------------------

Test case :

python aggregator.py sources.txt art

The following error messages should be generated:

Error opening url: http://invalidurlurlcs21a.com/

Error decoding url: http://www.deanza.edu/counseling/documents/Substitution%20Petition.pdf 'utf-8' codec can't decode byte 0xc4 in position 10: invalid continuation byte

The output file (artsummary.txt) should match the file artsummary.txtMy main function does not work fully as intended. I believe I.

Make sure you pick up references to Art and art and make sure you do NOT pick up the reference to arts.

Make sure you pick up the reference to Art when it is followed by punctuation as in: Recent acquisitions by the Art, Design...

-------------------

#------------------------------------------

sources.txt file:

http://web.archive.org/web/20180307004551/https://foothill.eduews/ http://web.archive.org/web/20151030182314/https://www.deanza.eduews/ http://web.archive.org/web/20151030182406/http://blogs.sjsu.eduewsroom/ http://web.archive.org/web/20151030182501/http:/ews.stanford.edu/ http://invalidurlurlcs21a.com/ http://web.archive.org/web/20151030182547/http:/ews.berkeley.edu/ http://web.archive.org/web/20151030182644/http://www.scu.edu/scunews/ http://web.archive.org/web/20151030172714/http:/ews.ucsc.edu/ http://web.archive.org/web/20151030183138/http://www.news.ucsb.edu/ http://web.archive.org/web/20151030183532/http://ucsdnews.ucsd.edu/ http://www.deanza.edu/counseling/documents/Substitution%20Petition.pdf

#------------------------------

Output file example

artsummary.txt file:

Source url:

http://web.archive.org/web/20151030182314/https://www.deanza.eduews/

Euphrat Museum of Art

Chain link fence art installation explores civil liberties issues

Euphrat Museum of Art exhibition features two student projects

Source url:

http://web.archive.org/web/20151030183138/http://www.news.ucsb.edu/

Recent acquisitions by the Art, Design & Architecture Museum explore

narratives of art and architecture

art

#--------------------------------

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!