I'm having trouble with the documentation on CSS class searching behavior. My goal is to match tags where a class has a specific, limited value only. For example:
soup.find_all('div', class_='abc')
I want this to match
<div class="abc">
but not match
<div class="def abc hij">
In referencing the documentation for
Searching by CSS class (
https://www.crummy.com/software/BeautifulSoup/bs4/doc/#searching-by-css-class), it's clear that "when you search for a tag that matches a certain CSS class, you’re matching against any of its CSS classes." This means the standard behavior will cause both of the above to match. However the workarounds are less clear. The next bit gives hope, stating that "You can also search for the exact string value of the class attribute," which sounds like exactly what I want, and it gives this example:
css_soup.find_all("p", class_="body strikeout")
However this seems predicated on having a multi-word string for the class? Removing one of the two words makes the example fall back on the default example in terms of syntax, meaning it's just going to match everything. Is there a way to denote that, even though I'm only providing one class name, I want the exact string value?