Question: Python: NOTE: The list item tag ( ) has an end item tag ( ) Write a function liParser(url) which will use a LineItemParser(HTMLParser) class

Python:

NOTE: The list item tag (

  • ) has an end item tag (
  • )

    Write a function liParser(url) which will use a LineItemParser(HTMLParser) class to collect and return a list of all strings which are to be in bold font in a given URL.

    Python: NOTE: The list item tag () has an end item tag

    Here's what I have:

    from html.parser import HTMLParser from urllib.request import urlopen import os

    class LineItemParser(HTMLParser): def __init__(self): self.reset() self.inListItemTag = False self.listrings = []

    def handle_starting(self, tag, attrs): if tag == 'li': self.inListItemTag = True

    def handle_tag(self, tag): if tag == 'li': self.inListItemTag = False

    def handle_data(self, data): if self.inListItemTag == True: self.listrings.append(data)

    def liParser(url): l = LineItemParser()

    try: response = urlopen(url) html = response.read()

    except URLError as e: print(e.reason)

    #error l.feed(html) print(l.listrings)

    there's an error on the l.feed(html)

    Help me fix this code!!!!

    >>> 1=LineltemPar3er ( ) >>>liParser ('http://facweb.cdm.depaul.edu/jhop1/Level1/page3.html' 'Click here for page 1', 'Click here for page 2', 'Click here for page 5' >>liParser ('http://facweb.cdm.depaul.edu/jhopl/' ['Click here for page,'Click here for page 2*, click here for page 3', Cli ck here for page 4', 'Click here for page 5', "Click here for page x

    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!