我尝试运行以下代码,但收到错误Beautifulsoup is not a module
:
import urllib
from Beautifulsoup import BeautifulSoup
webpage = urlopen('http://en.wikipedia.org/wiki/Mathematics').read
patfinderTitle = re.compile('<title>(.#)</title>')
if __name__=='__main__': main()
我试过'来自bs4', 使用Easy_install, Python 2.7, BeautifulSoup 3.2.1, 我该怎么办?
答案 0 :(得分:2)
实际模块名称为BeautifulSoup
(注意案例):
$ sudo easy_install beautifulsoup
$ python
>>> from BeautifulSoup import BeautifulSoup
对于bs4:
$ sudo easy_install beautifulsoup4
$ python
>>> from bs4 import BeautifulSoup