pythonによるスクレイピング
macの環境にBeautifulSoupをインストールします。
pip install BeautifulSoup4
…Successfully installed BeautifulSoup4-4.4.1
※古いバージョンをインストールしないよう注意
pip install BeautifulSoup
…Successfully installed BeautifulSoup-3.2.1
適当にCUIで試してみる。
from bs4 import BeautifulSoup
import urllib2,HTMLParser
page = urllib2.urlopen('hxxp://example.com')
soup=BeautifulSoup(page)
#a tag情報のみを取得
atag=soup.findAll('a')