Skip to content

Instantly share code, notes, and snippets.

@cpcloud
Last active December 18, 2015 00:19
Show Gist options
  • Select an option

  • Save cpcloud/5695835 to your computer and use it in GitHub Desktop.

Select an option

Save cpcloud/5695835 to your computer and use it in GitHub Desktop.
test bs4 + lxml
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
@cpcloud

cpcloud commented Jun 3, 2013

Copy link
Copy Markdown
Author

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?

@cpcloud

cpcloud commented Jun 3, 2013

Copy link
Copy Markdown
Author

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

@cpcloud

cpcloud commented Jun 3, 2013

Copy link
Copy Markdown
Author

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

@cpcloud

cpcloud commented Jun 3, 2013

Copy link
Copy Markdown
Author

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