BeautifulSoup and whitespace in attribute


from bs4 import BeautifulSoup
soup = BeautifulSoup("

soup.findAll('div',"class1") # works always
soup.findAll('div',"class 2") # works only is such way
soup.findAll('div',["class1","class 2"]) # does not work..


I suggest checking out their example-packed documentation:


i would personally do:


You can also used zip loops (depending on what you are achieving:

for x,y in zip(soup.find_all('div',class_='class1'),soup.find_all('div',class_='class2')):

Not sure that it is best practice, but pretty useful