BeautifulSoup(HTML)不工作,说不能调用模块? [英] BeautifulSoup(html) not working, saying can't call module?
本文介绍了BeautifulSoup(HTML)不工作,说不能调用模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import urllib2
import urllib
from BeautifulSoup import BeautifulSoup # html
from BeautifulSoup import BeautifulStoneSoup # xml
import BeautifulSoup # everything
import re
f = o.open( 'http://www.google.com', p)
html = f.read()
f.close()
soup = BeautifulSoup(html)
获得一个错误,说汤线= BeautifulSoup(HTML)说:'模块'对象不是可调用的。
推荐答案
您进口BeautifulSoup
,使 BeautifulSoup
指该模块,而不是类,因为它没有经过从BeautifulSoup进口BeautifulSoup
。如果你要导入整个模块,你可能想省略从...
行或者重命名后的类:
Your import BeautifulSoup
makes BeautifulSoup
refer to the module, not the class as it did after from BeautifulSoup import BeautifulSoup
. If you're going to import the whole module, you might want to omit the from ...
line or perhaps rename the class afterward:
from BeautifulSoup import BeautifulSoup
Soup = BeautifulSoup
...
import BeautifulSoup
....
soup = Soup(html)
这篇关于BeautifulSoup(HTML)不工作,说不能调用模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文