lundi 20 août 2018

Beautifulsoup if class exists

Is there a way to make BeautifulSoup look for a class and if it exists then run the script? I am trying this:

if soup.find_all("div", {"class": "info"}) == True:
    print("Tag Found")

I've also tried but it didn't work and gave an error about having too many attributes:

if soup.has_attr("div", {"class": "info"})
    print("Tag Found")

Aucun commentaire:

Enregistrer un commentaire