Last active
December 18, 2015 00:19
-
-
Save cpcloud/5695835 to your computer and use it in GitHub Desktop.
test bs4 + lxml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml.html import parse | |
url = 'http://www.fdic.gov/bank/individual/failed/banklist.html' | |
doc = parse(url) | |
print len(doc.xpath('.//table')) > 0 | |
from bs4 import BeautifulSoup | |
from contextlib import closing | |
from urllib2 import urlopen | |
with closing(urlopen(url)) as f: | |
soup = BeautifulSoup(f.read(), features='lxml') | |
print len(soup.find_all('table')) > 0 |
@wesm can u tell me what output u get here, when you get a chance?
oh i used to get this error when i had 2 versions of bs4 installed, since pip is dumb and allows you to install from source and from pypi, can u confirm that you don't have both installed?
for example
pip install beautifulsoup4
pip install -e 'bzr+lp:beautifulsoup#egg=beautifulsoup4'
will install two versions. i can't repro the test failure when i do that so that might not be the issue...alas
ok i've tried this on 32 and 64 bit ubuntu 12.04, arch linux latest and all tests pass. i'm going to try with anaconda
FINALLY i can repro this when using anaconda...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
u should see 2
True
s print out