我不明白为什么它不起作用。
现在我在财务表上工作:
https://finance.yahoo.com/quote/ATVI/financials?p=ATVI
我没有得到的是 find_all
方法的结果。
当我在上面放更多点符号时,比如 find_all('td').children
它抛出一个错误。
也许我的错误是因为 find_all
的返回值是一个对象,而不是一个列表,对吗?
我不知道为什么下面的代码不起作用。
span_tag1=soup.find_all('td')
for i in span_tag1.children:
print(i.get_text)
最佳答案
由于您正在查找 all
td
元素(这会创建一个列表),因此您需要遍历每个元素,然后找到每个 的子元素td
元素:
for td in soup.find_all('td'):
for child in td.children:
print(child.get_text())
关于python - 关于数据类型的 BeautifulSoup 代码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55509920/