1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

WebスクレイピングといえばBeautifulSoupですね。

GoogleClobを使えばすぐに試してみることができます。

from urllib.request import urlopen
import requests
from bs4 import BeautifulSoup
import bs4

#urlを変数に格納
url = 'https://ホームページ'

#データを取得
res = requests.get(url)

# HTMLからBeautifulSoupオブジェクトを作る
soup = BeautifulSoup(res.content, "html.parser")

# 全てのaを取得して格納
elems = soup.select('a')

# 配列からelemsから要素を取り出し処理する
for elem in elems:
print(elem.getText(), elem.get('href'))


参考文献

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?