| 12 | |
| 13 | |
| 14 | class Links(HTMLParser): |
| 15 | def __init__(self, page): |
| 16 | super().__init__() |
| 17 | self.urls = [] |
| 18 | self.feed(page.read_text()) |
| 19 | |
| 20 | def handle_starttag(self, tag, attrs): |
| 21 | if tag == "a": |
| 22 | self.urls.extend(value for key, value in attrs if key == "href") |
| 23 | |
| 24 | |
| 25 | class IncludeLinks(unittest.TestCase): |
no outgoing calls