File size: 372 Bytes
4df215f
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
from bs4 import BeautifulSoup
import requests

def get_earnings_news():
    url = "https://www.marketwatch.com/latest-news?mod=top_nav"
    response = requests.get(url)
    soup = BeautifulSoup(response.text, 'html.parser')

    headlines = []
    for tag in soup.select('.article__headline a')[:3]:
        headlines.append(tag.get_text(strip=True))
    return headlines