# -*- coding: utf-8 -*- import urllib from bs4 import BeautifulSoup url = "http://www.baidu.com" page = urllib.urlopen(url) soup = BeautifulSoup(page,"html.parser") print soup
# -*- coding: utf-8 -*- from bs4 import BeautifulSoup helloworld = '<p>Hello World</p>' soup_string = BeautifulSoup(helloworld, "html.parser") print soup_string
先安装:http://www.crummy.com/software/BeautifulSoup/bs4/download/4.3/beautifulsoup4-4.3.2.tar.gz