<pre>タグ内の一行だけスクレイピングしたい
Python3, requests, BeautifulSoup4でWebスクレイピングをしています。
発生している問題・エラーメッセージ
html<pre>内全体の整形された文字列は取得できるのですが、その中の一行のみ取り出したいです。
該当のソースコード
python
1import requests 2from bs4 import BeautifulSoup 3import cchardet 4 5target_url = 'http://www.data.jma.go.jp/sakura/data/sakura003_01.html' 6r = requests.get(target_url) 7soup = BeautifulSoup(r.content, 'html.parser', from_encoding=cchardet.detect(r.content)["encoding"]) 8table = soup.find("pre").contents[0] 9print(table)
補足情報(FW/ツールのバージョンなど)
Python 3.6.1
BeautifulSoup 4.6.0
requests 2.19.1
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。