Get the main topics of Yahoo News in Python.
> python -V
Python 3.8.2
requests and beautifulsoup4
> pip install requests beautifulsoup4
news.py
import requests
from bs4 import BeautifulSoup
html = requests.get('https://news.yahoo.co.jp')
yahoo = BeautifulSoup(html.content, "html.parser")
for title in yahoo.select(".topicsList_main li.topicsListItem a"):
print(title.getText())
> python news.py
Chinese public vessel invades territory for 2 consecutive days
Gifu shows 5 indicators of "exit strategy"
Mediation interruption Parent "I can't see my child"
Slander to nurses and family Kobe
Congratulations to Mr. Masaon Putin
Seoul entertainment facility banned
Little Richard dies
Yuzuki Muroi and Ryuichi Yoneyama to get married
Recommended Posts