0

我尝试运行以下代码,但出现错误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,我该怎么办?

4

1 回答 1

2

实际的模块名称是BeautifulSoup(注意大小写):

$ sudo easy_install beautifulsoup
$ python
>>> from BeautifulSoup import BeautifulSoup

对于 bs4:

$ sudo easy_install beautifulsoup4
$ python
>>> from bs4 import BeautifulSoup
于 2013-06-25T16:06:48.933 回答