Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON QUESTION: Complete the Boldface class so that when its process method is

ID: 3859049 • Letter: P

Question

PYTHON

QUESTION: Complete the Boldface class so that when its process method is called (with a URL as its parameter), it prints all text of the specified URL which is in boldface. You should use the HTMLParser class to make the coding easier.

Here is an example to illustrate how your program should work.

>>> b = Boldface()

>>> b.process('http://condor.depaul.edu/slytinen')

Steven Lytinen

Winter 2017 Schedule

Spring 2017 schedule

Research information

GIVEN CODE: (Just fill in what is given, question is above)

class Boldface(HTMLParser):
def __init__(self):
HTMLParser.__init__(self)
self.bold = False # indicates when we are in a <b> element

def handle_starttag(self, tag, attrs):
pass # fill this in

def handle_data(self, data):
pass # fill this in

def handle_endtag(self, tag):
pass # fill this in

def process(self, url):
self.feed(urlopen(url).read().decode())

Explanation / Answer

b.process('http://condor.depaul.edu/slytinen')

output

Steven Lytinen

Winter 2017 Schedule

Spring 2017 schedule

Research information