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

Need help with a python script that can complete the following, thanks for your

ID: 3768410 • Letter: N

Question

Need help with a python script that can complete the following, thanks for your time taken

Implement function getContent() that takes as input a URL (as a string) and prints only the text data content of the associated web page (i.e., no tags). Avoid printing blank lines that follow a blank line and strip the whitespace in every line printed.

>>> getContent('http://www.nytimes.com/')

The New York Times - Breaking News, World News & Multimedia Subscribe to The Times

Log In

Register Now

Home Page ...

Explanation / Answer

from HTMLParser import HTMLParser class MLStripper(HTMLParser): def __init__(self): self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def get_data(self): return ''.join(self.fed) def strip_tags(html): s = MLStripper() s.feed(html) return s.get_data()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote