Skip to content
Advertisement

Extract two div tags in one BS find_all

Is it possible to extract two HTML div tags in one “soup.find_all” with beautifulSoup? The divs are repeatedly called “event odd”, “event even” and i want to loop through them all

webpage code:

JavaScript

My code:

concerts = soup.find_all([‘div’, {‘class’: ‘event odd’}, {‘class’: ‘event even’}])

JavaScript

Advertisement

Answer

You can use Bitto Bennichan’s suggestion of using {'class': 'event'}.

Or, if you must specify two values at once, you can pass them in a list:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement