-
-
Save mprat/b042a834835cfb4bbe6c to your computer and use it in GitHub Desktop.
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
import requests | |
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"): | |
if story_heading.a: | |
print story_heading.a.text.replace("\n", " ").strip() | |
else: | |
print story_heading.contents[0].strip() |
error messege
Traceback (most recent call last):
File "C:/Users/JonahC/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/scratch.py", line 1, in
import requests
ModuleNotFoundError: No module named 'requests'
if you are using pymchar.clıck the alt enter .Click Alt + enter and it will automatically download the required module
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
error messege
Traceback (most recent call last):
File "C:/Users/JonahC/AppData/Roaming/JetBrains/PyCharmCE2020.1/scratches/scratch.py", line 1, in
import requests
ModuleNotFoundError: No module named 'requests'