LoginSignup
1
1

More than 3 years have passed since last update.

Pythonでスクレイピング

Last updated at Posted at 2020-08-23

BeautifulSoupの準備はこちら

最近モチベーション上がらなくて、上げるためにとりあえず書くことにしました。
本当に基礎の基礎なので悪しからず

とりあえず、BeautifulSoupを実行してみます。

from urllib.request import urlopen
from bs4 import BeautifulSoup

# 取得するページ
html = urlopen('http://www.pythonscraping.com/pages/page1.html')
bs = BeautifulSoup(html.read(), 'html.parser')
# h1タグを返す
print(bs.h1)

2行目の

from bs4 import BeautifulSoup

部分でBeautifulSoupをインポートする。
実行結果は下記となる。
WS000000.JPG

http://www.pythonscraping.com/pages/page1.html
上記ページのh1タグだけ取得できることがわかる。

次回はちゃんとした内容で投稿します。

参考文献

PythonによるWebスクレイピング(オライリー・ジャパン)

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