简体   繁体   中英

Simple example BeautifulSoup Python

I was working a simple example with BeautifulSoup, but I was getting weird resutls.

Here is my code:

soup = BeautifulSoup(page)
print soup.prettify()
stuff = soup.findAll('td', attrs={'class' : 'prodSpecAtribtue'})
print stuff

When I print I get:

[]

Not sure what's happening, because when I printed soup on the screen I got proper data. Basically I am searching for values in found in tag <td> under class prodSpecAtribtue

You misspelled the class name:

soup.findAll('td', attrs={'class': 'prodSpecAtribute'})

works fine. That's prodSpecAtribute , not prodSpecAtribtue . That's still misspelled, but slightly less so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM