{"id":1083,"hash":"0e3f737df9721b6889bcd44270ed272eda321597bdd330deebe0346bdf5df162","pattern":"Beautiful Soup cannot find a CSS class if the object has other classes, too","full_message":"if a page has <div class=\"class1\"> and <p class=\"class1\">, then soup.findAll(True, 'class1') will find them both.\n\nIf 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?","ecosystem":"pypi","package_name":"screen-scraping","package_version":null,"solution":"Just in case anybody comes across this question. BeautifulSoup now supports this:\n\nPython 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]\nType \"copyright\", \"credits\" or \"license\" for more information.\n\nIn [1]: import bs4\n\nIn [2]: soup = bs4.BeautifulSoup('<div class=\"foo bar\"></div>')\n\nIn [3]: soup(attrs={'class': 'bar'})\nOut[3]: [<div class=\"foo bar\"></div>]\n\nAlso, you don't have to type findAll anymore.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/1242755/beautiful-soup-cannot-find-a-css-class-if-the-object-has-other-classes-too","votes":41,"created_at":"2026-04-19T04:52:18.515234+00:00","updated_at":"2026-04-19T04:52:18.515234+00:00"}