エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
スクレイピングのサンプル - Qiita
from urllib.request import urlopen from bs4 import BeautifulSoup from pprint import pprint URL = ... from urllib.request import urlopen from bs4 import BeautifulSoup from pprint import pprint URL = 'http://news.yahoo.co.jp/' with urlopen(URL) as res: html = res.read().decode("utf-8") soup = BeautifulSoup(html, 'html.parser') titles = soup.select('.ttl a') # domを取得 titles = [t.contents[0] for t in titles] # テキストを取得 pprint(titles)

