前提
BeautifulSoupでWEBスクレイピングをしたい
実現したいこと
WEBスクレイピングにてDIVタグ内のa hrefのURLのみ抽出したい
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
<a href="https://www.kjrm.co.jp/" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/kjrmanagement.PNG"/> </a> <a href="https://www.yayoi-kk.co.jp/index.html" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/yayoi.PNG"/> </a> <a href="http://www.cttc.co.jp/index.html" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/ctt.PNG"/> </a> <a href="https://www.seiyu.co.jp/" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/seiyu.PNG"/> </a> <a href="https://www.kokusai-electric.com/" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/468.png"/> </a> <a href="http://www.hitachi-kokusai.co.jp/" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/hitachi_1.png"/> </a> <a href="https://www.koki-holdings.co.jp/" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/kokiHD.png"/> </a> <a href="https://www.marelli-corporation.com/index.html" target="_blank"> <img class="img-responsive" src="https://pefund.jp/wp-content/themes/integroup2020/uploads/investee/marelli.PNG"/> </a>python
1r = requests.get("https://pefund.jp/funds/jph/") 2c = r.content 3soup = BeautifulSoup(c, "html.parser") 4 5div_container = soup.find_all('div', class_='max-width-40px large-max-width-100px center-block text-center') 6 7for v in div_container: 8 print(v.find('a')) 9
ここから
https://www.kjrm.co.jp/
https://www.yayoi-kk.co.jp/index.html
等の8つのURLのみを取得したいです
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー