python bs4找不到div [英] python bs4 not finding div
问题描述
我正在尝试刮除 https://www.edsurge.com/产品评论/课程产品/数学
当我这样做时:
site = 'https://www.edsurge.com/product-reviews/curriculum-products/math'
soup = bs.BeautifulSoup(urlopen(site),"html5lib")
print soup
我可以找到要查找的div <div class="browse-main p1">
I can find the div I am looking for <div class="browse-main p1">
但是,当我尝试使用以下方法找到它时:
However, when I try to find it using:
for div in soup.findall('div',class_='browse-main p1'):
print div
我收到此错误(可能意味着它找不到div).
I get this error (probably meaning that it can't find the div).
for div in soup.findall('div',class_='browse-main p1'):
TypeError: 'NoneType' object is not callable
我也尝试使用soup.findall('div')
,但找不到任何内容.
我知道我可以使用硒,但是如果没有必要,我宁愿不用.我感到奇怪的是,当我打印汤时div出现了.
I also tried using soup.findall('div')
and it can't find any.
I know I could use selenium, but if it is not necessary, I would rather not. What I find odd is that the div is present when I print soup.
任何人都知道发生了什么事吗? 谢谢
Anyone know what is going on ? Thanks
推荐答案
findall
为无,因此无法调用.
The findall
is None, so its uncallable.
尝试:
for div in soup.findAll('div',class_='browse-main p1'):
这篇关于python bs4找不到div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!