Last active
February 21, 2019 03:40
-
-
Save mitchellvitez/7104a336b7c611f61920f3c68c6ee445 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 requests | |
| from bs4 import BeautifulSoup | |
| def soupify(url): | |
| page = requests.get(url) | |
| return BeautifulSoup(page.text, 'html.parser') | |
| parks = soupify('https://www.nps.gov/planyourvisit/fee-free-parks-state.htm').find_all('a') | |
| for park in parks: | |
| if park['href'].startswith('https://www.nps.gov'): | |
| address = soupify(park['href']).find(attrs={'itemprop': 'address'}) | |
| if address: | |
| print(park.contents[0]) | |
| print(park['href']) | |
| print(' '.join(address.text.split())) | |
| print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment