Beautiful soup queries <p>I'm struggling to have queries in BS with multiple conditions of the type AND or OR. From what I read I have to use lambda. As an example, I'm looking for tags that match either "span", {"class":"green"} or tag.name == "h1" on the page <a href="http://www.pythonscraping.com/pages/warandpeace.html" rel="nofollow">http://www.pythonscraping.com/pages/warandpeace.html</a></p> <p>I manage to get them separately using the lambda syntax:<br> <code>bsObj.findAll(lambda tag: tag.name == "h1")</code> will return h1<br> <code>bsObj.findAll(lambda tag: tag.name == "span", {"class":"green"})</code> wil return span green </p> <p>Or I can get all "span" tags and "h1" :<br> <code>bsObj.findAll(lambda tag: tag.name == "span" or tag.name == "h1")</code> return span green and red as well as h1</p> <p>But I don't manage to get the span of <strong>class green or h1</strong>, as the following code does not provide the right result :<br> <code>bsObj.findAll(lambda tag: tag.name == "span", {"class":"green"} or tag.name == "h1")</code></p> <p>Can please someone explain me the right way to do it in <strong>one</strong> query ? Goal here is not only to get the result but rather understand the syntax. Thanks !</p> <p>(using Python 3.4)<br> PS : I think this issue is different from the the one here: <a href="http://stackoverflow.com/questions/18725760/beautifulsoup-findall-given-multiple-classes">BeautifulSoup findAll() given multiple classes?</a> as well as a variation of <a href="http://stackoverflow.com/questions/20648660/python-beautifulsoup-give-multiple-tags-to-findall?rq=1">Python BeautifulSoup give multiple tags to findAll</a> (as we want a specific attribute)</p>