前提・実現したいこと
発生している問題・エラーメッセージ
スクレイピングのコードを書いたのですが、htmlが表示されません。
どこに問題があるのか教えていただけますと幸いです。
エラーメッセージ:無し
該当のソースコード
Python
1import urllib.request 2from bs4 import BeautifulSoup 3 4class Scraper: 5 def __init__(self,site): 6 self.site = site 7 8 def scrape(self): 9 r = urllib.request.urlopen(self.site) 10 html = r.read() 11 parser = "html.parser" 12 sp = BeautifulSoup(html,parser) 13 for tag in sp.find_all("a"): 14 url = tag.get("href") 15 if url is None: 16 continue 17 if "href" in url: 18 print(url) 19 20news = "https://news.google.com/" 21Scraper(news).scrape()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/07 15:00