【发布时间】:2019-12-18 19:14:01
【问题描述】:
为什么会出现此错误? (我知道这个问题缺乏很多细节,但我很着急,我的代码很简单,如果有人帮助我,我会很感激)
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
【问题讨论】:
-
你检查过
page_soup的值吗? -
适用于
page_soup.find_all,但我认为这个元素是用 JS 动态生成的。您可以编辑问题以询问此问题并修正错字。
标签: python html python-3.x web-scraping beautifulsoup