先说结论:拼写大小写错误。BeatufulSoup并没有findall(),但有findAll()。
而BS4推荐使用find_all(),这个findAll仅仅是为了兼容BS3,

事情是这样的:
soup = BeautifulSoup(html, 'html.parser')
trs = soup.find(id="grid").find("tbody").findAll("tr")
for tr in trs:
tds=tr.findall("td")
BeautifulSoup 执行tds=tr.findall("td")报错: TypeError: 'NoneType' object is not callable

换成findChildren则成功:
soup = BeautifulSoup(html, 'html.parser')
trs = soup.find(id="grid").find("tbody").findAll("tr")
for tr in trs:
tds = tr.findChildren()
一阵莫名奇怪,排查才发现,原来是大小写拼写错误。
最后
以上就是失眠人生最近收集整理的关于BeautifulSoup 执行tds=tr.findall(“td“)报错的全部内容,更多相关BeautifulSoup内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复