Answer the question
In order to leave comments, you need to log in
How to make BS4 look for tags with class1 but not class2?
How to make BS4 not include tags that have a specific class. For example, there is an a tag that has class1 and class2, it is not needed, but there is an a tag that has only class1, which is just needed.
Answer the question
In order to leave comments, you need to log in
tags = soup.findAll('tag_name',{'class':'class1'})
class1 = []
for tag in tags:
if tag['class'] == 'class1':
class1.append(tag)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question