from bs4 import BeautifulSoup # To get everything
==解析==
*===文字列およびファイルハンドルによる文書解析===
soup = BeautifulSoup(open("index.html"))
soup = BeautifulSoup("<html>data</html>")
*===URLを指定して解析===
*[[https://docs.python.org/ja/2.7/library/urllib2.html urllib2 モジュールは、Python 3 で urllib.request, urllib.error に分割されました。]]
<pre>
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib.request.urlopen('http://xxxxx.com'))
</pre>
===エンコードの変換===
*文字化けする場合(例えばSHIFT-JIS)の対処
<pre>
response = urllib.request.urlopen(url)
html = response.read().decode(response.headers.get_content_charset(), errors='ignore')
parsed_html = BeautifulSoup(html, 'html.parser')
</pre>