サイトからタイトルのみをスクレイピングで取得したい。

前提

Pythonでスクレイピングをしたいです。
どうしても、うまくいかず助けていただきたいです。

実現したいこと

・こちらのサイト(https://blog.hatenablog.com/entry/2022/06/13/120000)から、
すべてのタイトルを取り出したいですイメージ説明

発生している問題・エラーメッセージ

https://blog.hatena.ne.jp/hatenablog/blog.hatenablog.com/subscribe?utm_campaign=subscribe_blog&utm_source=blogs_topright_button&utm_medium=button https://hatenablog.com?utm_source=weeklyHatenaBlog&utm_medium=referral&utm_campaign=globalNavbar /archive/category/Feature /archive/category/Topic /archive/category/Odai /archive/category/Editor's%20Pick /archive/category/Information / https://blog.hatenablog.com/pro-monetize-campaign /archive/category/Feature /archive/category/Topic /archive/category/Odai /archive/category/Editor's%20Pick /archive/category/Information https://blog.hatenablog.com/archive/2022/06/13 (省略)

該当のソースコード

Python

load_url = "https://blog.hatenablog.com/entry/2022/06/13/120000"html = requests.get(load_url)soup = BeautifulSoup(html.content, "html.parser") for element in soup.find_all("a"): url = element.get("href") print(url)

試したこと

上のように、実行してもURLしか取得できず、肝心のタイトル(文字列)が所得できません。
恐らく、要素の指定の仕方が間違っていると思うのですが、
自力では解決できそうもなく、ご教示いただきたいです。

コメントを投稿

0 コメント