Beautifulsoup(html) Not Working, Saying Can't Call Module?
import urllib2 import urllib from BeautifulSoup import BeautifulSoup # html from BeautifulSoup import BeautifulStoneSoup # xml import BeautifulSoup # ever
Solution 1:
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 importBeautifulSoupSoup= BeautifulSoup
...
import BeautifulSoup
....
soup = Soup(html)
Solution 2:
@Blair's answer has the right slant but I'd perform some things slightly differently, i.e.:
importBeautifulSoupSoup= BeautifulSoup.BeautifulSoup
(recommended), or
importBeautifulSoupfromBeautifulSoupimportBeautifulSoupasSoup
(not bad either).
Solution 3:
Install BeautifulSoup4 sudo easy_install BeautifulSoup4
Recommendation from bs4 import BeautifulSoup
Post a Comment for "Beautifulsoup(html) Not Working, Saying Can't Call Module?"