Scrapy 错误 - str 对象没有属性 css

问题描述 投票:0回答:1
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 shell 中抓取网站时遇到此错误。

python scrapy
1个回答
0
投票

getall()
以字符串形式返回提取的数据,如果您只想选择器,则不要调用它:

Article = response.css(‘.article-main)
Art =article [0]
Art.css(‘.art2-amp::text’).get()
© www.soinside.com 2019 - 2024. All rights reserved.