scrapy AttributeError: 'str' object has no attribute 'xpath'

错误代码示例:

    def parse(self, response):
        for news in response.xpath('//*[@class="Q-tpList"]/div/div/em').extract():
            title = news.xpath('a/text()').extract()[0].strip()

解决方法:

把第二行xpath的.extract()删掉

猜你喜欢

转载自blog.csdn.net/qq_18525247/article/details/81912030