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 中抓取网站时遇到此错误。
getall()
以字符串形式返回提取的数据,如果您只想选择器,则不要调用它:
Article = response.css(‘.article-main)
Art =article [0]
Art.css(‘.art2-amp::text’).get()