我得到一个AttributeError:“HtmlResponse”对象在scrapy中没有属性“xpath”

2024-04-20 00:38:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我对scrapy很熟悉,我正在使用scrapy 0.14.4。我只想按照下面的例子打印标题和链接。

这是我的蜘蛛:

from scrapy.spider import BaseSpider

class XxxSpider(BaseSpider):
    name = "xxx"
    allow_domains = ["xxx.xxx.xxx"]
    start_urls = ["http://xxx.xxx.com/jobs/"]


    def parse(self, response):
        for sel in response.xpath("//div[@id='job_listings']/a"):
            title = sel.xpath('./text()').extract()
            link = sel.xpath('./@href').extract()
            print title, link

这里面少了什么?


Tags: from标题title链接responselinkextractxpath