Created
October 28, 2016 04:17
-
-
Save slmcmahon/7f966736a893da95b2c8a1d3fedb64ed to your computer and use it in GitHub Desktop.
Show a listing of links to the most popular Houston, TX stories in the Houston Chronicle.
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
from bs4 import BeautifulSoup | |
import requests | |
result = requests.get("http://www.chron.com/news/houston-texas/") | |
soup = BeautifulSoup(result.content, 'html.parser') | |
items = soup.find_all('a', 'hdn-analytics') | |
for link in [l for l in items if 'most_popular' in l.attrs['data-hdn-analytics']]: | |
print('<a href="{}">{}</a>'.format(link.attrs['href'], link.attrs['title'])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment