AttributeError ResultSet object has no attribute text Youre probably treating a list of elements like a single element Did you call find_all when you meant to call find
This error message is indicating that you are trying to access the text attribute on a ResultSet object, which is incorrect because ResultSet objects do not have a text attribute.
The most likely cause of this error is that you are treating a list of elements, returned by the find_all() method, as a single element and trying to access the text attribute on it.
To resolve this issue, you should iterate over the ResultSet object to access the individual elements, and then access the text attribute on each element separately. For example:
results = soup.find_all('div', class_='my-class')
for result in results:
print(result.text)
In this example, soup is the BeautifulSoup object, and find_all() is used to find all <div> elements with a specific class. The loop then iterates over each individual element in the results list, and the text attribute is accessed on each element separately
原文地址: https://www.cveoy.top/t/topic/iynC 著作权归作者所有。请勿转载和采集!