Yahooニュースのコメントのスクレイピングをしたいのですが、コメント部分がIframeで書かれており、その部分を取ることができません。
上の部分を抽出したいのですが、(https://news.yahoo.co.jp/pickup/6320720)、正直にiframeの部分をスクレイピングしようとしてもできません。どなたかご教授頂けないでしょうか?
python
1from bs4 import BeautifulSoup 2import urllib.request as req 3 4url = "https://news.yahoo.co.jp/pickup/6320720" 5res = req.urlopen(url) 6soup = BeautifulSoup(res, "html.parser") 7 8#comment_list = soup.select('div') 9comment_list = soup.find('div', class_ = "news-comment-plugin") 10iframe_list = soup.select("iframe") 11 12print(iframe_list) 13 14#print(comment_list) 15#print(comment_list["data-full-page-url"]) 16
のコードで出力は、
[<iframe frameborder="0" height="1" marginheight="0" marginwidth="0" scrolling="no" src="//b.yjtag.jp/iframe?c=8P8rc6G" width="1"></iframe>]
となりました。
更にコメントアウトしているところで、commentのフル表示のページにも行きましたが、やはりIframeの中のデータを取ることができません。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/19 04:45