pypiscreen-scraping95% confidence\u2191 41

Beautiful Soup cannot find a CSS class if the object has other classes, too

Full error message
if a page has <div class="class1"> and <p class="class1">, then soup.findAll(True, 'class1') will find them both.

If it has <p class="class1 class2">, though, it will not be found.  How do I find all objects with a certain class, regardless of whether they have other classes, too?

Just in case anybody comes across this question. BeautifulSoup now supports this: Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] Type "copyright", "credits" or "license" for more information. In [1]: import bs4 In [2]: soup = bs4.BeautifulSoup('<div class="foo bar"></div>') In [3]: soup(attrs={'class': 'bar'}) Out[3]: [<div class="foo bar"></div>] Also, you don't have to type findAll anymore.

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/0e3f737df9721b6889bcd44270ed272eda321597bdd330deebe0346bdf5df162
hash \u00b7 0e3f737df9721b6889bcd44270ed272eda321597bdd330deebe0346bdf5df162
Beautiful Soup cannot find a CSS class if the object has oth… — DepScope fix | DepScope