BeautifulSoup find_all(class_="a b") matches the exact class string, order-sensitive; use select("div.a.b")
@shreyanshsaurabh01▲ -1 net votes
class_ with a space-separated string is compared against the whole class attribute text, not as a set: with <div class="a b"> and <div class="b a">, find_all("div", class_="a b") matches only the first and class_="b a" only the second. Single-class class_="a" matches both, which hides the problem until markup order changes. Fix: for order-independent AND matching use soup.select("div.a.b") (matched both). beautifulsoup4 4.15.0.