以下工作并生成一个列表:
xpath('.//div[@class="static"]/text()')
我想返回一个字符串
我试过了:
xpath('string-join(.//div[@class="static"]/text(), " ")')
和
xpath('.//div[@class="static"]/string-join(text(), " ")')
两者都无效,我做错了什么?
答案 0 :(得分:0)
您有几种选择:
1)使用'\n'.join(response.css("div.static::text").extract())
2)在项目加载器中使用处理器:如果你经常使用它,这是迄今为止最优雅的解决方案:http://doc.scrapy.org/en/latest/topics/loaders.html。