简体   繁体   English

简单示例BeautifulSoup Python

[英]Simple example BeautifulSoup Python

I was working a simple example with BeautifulSoup, but I was getting weird resutls. 我在BeautifulSoup上工作了一个简单的例子,但结果却很奇怪。

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 基本上我在prodSpecAtribtue类的标签<td>搜索值

You misspelled the class name: 您拼写了错误的类名:

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

works fine. 工作正常。 That's prodSpecAtribute , not prodSpecAtribtue . 那是prodSpecAtribute而不是 prodSpecAtribtue That's still misspelled, but slightly less so. 仍然拼错了,但是少了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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