PythonでYahoo!のトピックス一覧を取得する

Pythonのfind_allメソッドでYahoo!のトピックス一覧を取得してみました。

import requests
from bs4 import BeautifulSoup, element

LOAD_URL = "https://news.yahoo.co.jp/topics"
html = requests.get(LOAD_URL)
soup = BeautifulSoup(html.content, "html.parser")
filename = "topis.txt"
with open(filename, "w") as f:
    for element in soup.find_all(class_="sc-ksYbfQ gSBRIC"):
        f.write(f'{element.text}\n')