Created
May 23, 2015 20:43
-
-
Save logston/ed7178ba8061895e9e2a to your computer and use it in GitHub Desktop.
Python Office Hours 2015-05-23
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 | |
| import bs4 | |
| resp = requests.get('http://nycpython.org') | |
| soup = bs4.BeautifulSoup(resp.content) | |
| tags = soup.find_all('a') | |
| hrefs = [tag.get('href') for tag in tags] | |
| with open('links.txt', 'w') as fd: | |
| for href in hrefs: | |
| fd.write(href + '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment