Skip to content

Instantly share code, notes, and snippets.

@calthoff
Created April 5, 2018 06:24
Show Gist options
  • Select an option

  • Save calthoff/7539e72d3c3f4e97617d9fbd7eb152b8 to your computer and use it in GitHub Desktop.

Select an option

Save calthoff/7539e72d3c3f4e97617d9fbd7eb152b8 to your computer and use it in GitHub Desktop.
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