금융을 따라 흐르는 블로그
scraping the headlines from the CNN website 본문
import requests
from bs4 import BeautifulSoup
url = 'https://www.cnn.com/'
#네이버로 바꾸고 싶으면 www.naver.com
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
headlines = soup.find_all('h2', class_='cd__headline')
for headline in headlines:
print(headline.text.strip())