Beautifulsoup multiple class selector

table = soup.find_all("tr",class_=["odd","even"])

Try this way! Make sure you are using proper structure of those quotes and braces. It confused me.


You can use CSS selectors instead, which is probably the best solution here.

soup.select("div.classname1.classname2")

You could also use a function.

def interesting_tags(tag):
    if tag.name == "div":
        classes = tag.get("class", [])
        return "A" in classes and "B" in classes

soup.find_all(interesting_tags)

Use css selectors instead:

soup.select('div.A.B')