AttributeError: ResultSet object has no attribute ‘find_all‘.

时间:2024-03-17 11:05:40

AttributeError: ResultSet object has no attribute ‘find_all’. You’re probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
意思是:属性错误:ResultSet对象没有属性’find_all’。您可能将一个元素列表当作一个元素来处理。当您打算调用find()时,是否调用了find_all() ?

在爬取https://www.shicimingju.com/book/xiyouji.html时想要提取文章标题和标题内容到txt文件里出现以下错误:
AttributeError: ResultSet object has no attribute ‘find_all‘.
点开浏览器开发者工具看:a标签是存在于li标签中
AttributeError: ResultSet object has no attribute ‘find_all‘.
但是soup.select(’.book-mulu li’)返回的是一个列表对象,列表对象没有find_all方法,所以显示报错
AttributeError: ResultSet object has no attribute ‘find_all‘.
完整的爬取程序如下:
AttributeError: ResultSet object has no attribute ‘find_all‘.
打开当前目录下的西游记.txt文件:
AttributeError: ResultSet object has no attribute ‘find_all‘.