Skip to content

Instantly share code, notes, and snippets.

@MartMcMahon
Created May 27, 2020 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MartMcMahon/dbe7ee2fb549c2ef1441f3af3e7f16f9 to your computer and use it in GitHub Desktop.
Save MartMcMahon/dbe7ee2fb549c2ef1441f3af3e7f16f9 to your computer and use it in GitHub Desktop.
basic web scraping
from bs4 import BeautifulSoup
import requests
def get_page(url):
page = requests.get(url)
page_str = page.text
soup = BeautifulSoup(page_str, "html.parser")
html_h1s = soup.find_all("h1")
for h1 in html_h1s:
print(h1)
if __name__ == "__main__":
url = "https://www.merriam-webster.com/dictionary/cache"
get_page(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment