Print out a list of all headline titles on the New York Times homepage.
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|
|base_url = 'http://www.nytimes.com'|
|r = requests.get(base_url)|
|soup = BeautifulSoup(r.text)|
|for story_heading in soup.find_all(class_="story-heading"):|
|print story_heading.a.text.replace("\n", " ").strip()|