Question: Write a function getWebInfo( ) that takes as input a URL and prints the following information: 1) A list of all absolute links that are
Write a function getWebInfo( ) that takes as input a URL and prints the following information:
1) A list of all absolute links that are already in the page, that is links that start with 'http://' or 'https://'. Do not copy code from the book, which is using urljoin to make every link absolute. 2) A list of all data tokens in the page. Make sure the tokens contain only alphanumeric data. The list should have no duplicates. 3) The count of the total number of anchor tags.
?Must use HTMLparser class methods
?Please post a screenshot of your answer ?Starting code below:

14 Web page processing 2 from urllib.request import urlopen 4 from html.parser import HTMLParser 5 class LinkParser (HTMLParser): 6 -init-(self): HTM L Parser . def init_(self) - 8 9 10 def handle_starttag(self, tag, attrs): if tag-' a' : # if anchor tag print ('a attrs = ', attrs) 12 13 def handle data(self, data): 14 15 16 17 def getWebInfo(url): 18 19 20 21 22 getwebInfo ('http://www.cdm.depaul.edu/) 23 24 if data.isalnun(): # f data is alphanumeric print( DATA,data) contenturlopen (url).read().decode() linkparser - LinkParser() linkparser.feed(content) 14 Web page processing 2 from urllib.request import urlopen 4 from html.parser import HTMLParser 5 class LinkParser (HTMLParser): 6 -init-(self): HTM L Parser . def init_(self) - 8 9 10 def handle_starttag(self, tag, attrs): if tag-' a' : # if anchor tag print ('a attrs = ', attrs) 12 13 def handle data(self, data): 14 15 16 17 def getWebInfo(url): 18 19 20 21 22 getwebInfo ('http://www.cdm.depaul.edu/) 23 24 if data.isalnun(): # f data is alphanumeric print( DATA,data) contenturlopen (url).read().decode() linkparser - LinkParser() linkparser.feed(content)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
