BeautifulSoup and whitespace in attribute


#1

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..

#2

I suggest checking out their example-packed documentation:
http://www.crummy.com/software/BeautifulSoup/bs4/doc/#find-all


#3

i would personally do:

soup.find_all('div',class_='class1')

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')):
    print(x)
    print(y)

Not sure that it is best practice, but pretty useful