Let's say I have 4 links:
<a href="#1" id="xyz" class="monte">hi</a>
<a href="#3" id="qrs" class="sam">hi</a>
<a href="#6" id="mno" class="alex">hi</a>
<a href="#9" id="abc" >hi</a>
I want to return the href, class and id for all elements that do NOT have the class = "monte" ... including the one element without a class element at all. Let's assume the above is called html
Is there a NOT operator such as !
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, "html.parser") # or lxml
result = soup.find_all('a', {"class": !"monte"})
for link in result:
print(link.get("href"));
print(link.get("class"));
print(link.get("id"));
Using selenium driver, I would like to click on any of the found elements. Assume that I may not have a unique id to identify what to click on. That is, I may need to use find_element_by_xpath. I do have a unique data-id.