AttributeError: 'NoneType' 对象没有属性 'text' ,我不明白如何修复它

2024-04-11

我正在尝试使用 python 读取文件并将每一行作为函数的参数。我收到 AttributeError: 'NoneType' object has no attribute 'text' 错误,我不明白如何修复它。

from bs4 import BeautifulSoup

from requests_html import HTMLSession

session = HTMLSession()

response = session.get('https://pool.rplant.xyz/#')

soup = BeautifulSoup(response.content, 'html.parser')

nah = soup.find('span', {'id': 'statsPoolMc'}).text

print(nah)

该元素不存在。大概是因为汤.查找实际上什么也没发现。所以你必须编辑你要查找的内容。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AttributeError: 'NoneType' 对象没有属性 'text' ,我不明白如何修复它 的相关文章

随机推荐