bs4-BeautifulSoup,TypeError:'NoneType'对象不可调用

时间:2019-12-18 19:14:01

标签: python html python-3.x web-scraping beautifulsoup

为什么会出现此错误? (我知道这个问题缺少很多细节,但是我很着急,我的代码非常简单,所以如果有人帮助我会很感激)

from urllib.request import urlopen as ureq
from bs4 import BeautifulSoup

url = 'https://www.macrotrends.net/stocks/charts/BABA/alibaba/balance-sheet'

client = ureq(url)
page_html = client.read()
client.close()

page_soup = BeautifulSoup(page_html, 'html.parser')
balance_sheet = page_soup.findALL("div",{"id":"row10jqxgrid"})
balance_sheet
TypeError                                 Traceback (most recent call last)
<ipython-input-81-6a2377c6bfca> in <module>
      1 page_soup = BeautifulSoup(page_html, 'html.parser')
----> 2 balance_sheet = page_soup.findALL("div",{"id":"row10jqxgrid"})
      3 balance_sheet

TypeError: 'NoneType' object is not callable

1 个答案:

答案 0 :(得分:2)

balance_sheet = page_soup.findALL("div",{"id":"row10jqxgrid"})

在您的代码中,您已经用大写字母写了findAll。 写findAll而不是findALL

balance_sheet = page_soup.findAll("div",{"id":"row10jqxgrid"})