Created
August 7, 2016 07:46
-
-
Save BensonMuriithi/b22d1556b4295211c831e94798440990 to your computer and use it in GitHub Desktop.
My solution for 'Decode A Web Page' exercise on practicepython.org ->http://www.practicepython.org/exercise/2014/06/06/17-decode-a-web-page.html
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
"""Get all <article> tags on New York Times homepage""" | |
import requests | |
from bs4 import BeautifulSoup | |
def get_articles(address): | |
page = requests.get(address) | |
soup = BeautifulSoup(page.text, "html.parser") | |
return list(soup.find_all("article")) | |
if __name__ == "__main__": | |
print get_articles("http://www.nytimes.com/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment