Created
April 5, 2018 06:24
-
-
Save calthoff/7539e72d3c3f4e97617d9fbd7eb152b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib.request | |
| from bs4 import BeautifulSoup | |
| class Scraper: | |
| def __init__(self, site): | |
| self.site = site | |
| def scrape(self): | |
| r = urllib.request.urlopen(self.site) | |
| html = r.read() | |
| parser = "html.parser" | |
| sp = BeautifulSoup(html, parser) | |
| for tag in sp.find_all("a"): | |
| url = tag.get("href") | |
| if url is None: | |
| continue | |
| if "html" in url: | |
| print("\n" + url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment