Created
May 27, 2020 05:20
-
-
Save MartMcMahon/dbe7ee2fb549c2ef1441f3af3e7f16f9 to your computer and use it in GitHub Desktop.
basic web scraping
This file contains 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
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