早朝、YOUTUBEライブ配信で行ったものはタイトルとリンクが若干異なるところがあったので、修正したソースコードを貼っときます。Python言語少しずつ 少しずつ理解できてきた。
書き方が慣れればPHPより書くのは楽かな。$の記号がPHPの変数を書く場合、絶対必要になるけどPythonは書かなくて良いからね。
import requests
from bs4 import BeautifulSoup
r = requests.get("https://news.yahoo.co.jp/")
soup = BeautifulSoup(r.content, "html.parser")
#ニュース一覧のテキストのみ抽出
f = open("link.csv",mode = "a")
for t,a in zip(soup.find_all("div", "newsFeed_item_title"),soup.find_all("a", "newsFeed_item_link")):
f.write(t.text + "," + a.get('href') + "\n")
f.close()