ここではPythonで行うHTML解析 (パース)を解説します。取得したHTMLから様々な処理を行うことができます。 HTML文字列の取得 5行目で指定URLをオープンし、6行目で取得したHTML文を表示しています。 Python 3系 import urllib.request url = 'http://www.python-izm.com/' htmldata = urllib.request.urlopen(url) print(htmldata.read().decode('UTF-8')) htmldata.close() Python 2系ではurllib2モジュールなので注意してください。 Python 2系 # -*- coding: utf-8 -*- import urllib2 url = 'http://www.python-izm.com/' htmldata
