Scrapy错误 - str对象没有css属性
Article = response.css(‘.article-main).getall()
Len(article)
到这里我们得到了结果
Art =article [0]
Art.css(‘.art2-amp::text’).get()
遇到错误
str object has no attribute css. Note html tags are example in css given
我该怎么解决这个问题?我在用Scrapy抓取网站时遇到了这个错误。
1 个回答
0
getall()
这个函数会把提取到的数据以字符串的形式返回。如果你只想要选择器,那就不要调用这个函数。
Article = response.css(‘.article-main)
Art =article [0]
Art.css(‘.art2-amp::text’).get()