未输入scrapy回调函数

未输入scrapy回调函数,scrapy,Scrapy,我一直在寻找解决办法,但我发现没有一个对我有效。在花了两天时间调试之后,我应该向你们寻求帮助 URL看起来不错。即使我在请求代码之前硬编码了一个url,回调函数仍然不起作用 我的代码是: def parse_link(self, response): print 'lllll', response.url print 'bbbbb', len(response.body), response.body def parse(self

我一直在寻找解决办法,但我发现没有一个对我有效。在花了两天时间调试之后,我应该向你们寻求帮助

URL看起来不错。即使我在请求代码之前硬编码了一个url,回调函数仍然不起作用

我的代码是:

    def parse_link(self, response):
            print 'lllll', response.url
            print 'bbbbb', len(response.body), response.body

    def parse(self, response):
            hxs = HtmlXPathSelector(response)
            issues = hxs.select('//a//@id').extract()
            for i in range(len(issues)):
                    issue = issues[i]
                    links_2d = hxs.select('//html//body//table[%d+%d]/tr/td//a[contains(text(),"full quotes")]/@href' % (9, i)).extract()
                    links_2d = list(set(links_2d))

                    if len(bb) < 1: continue
                    if len(links_2d) < 1: continue

                    full_link = links_2d[0]

                    yield scrapy.Request(url=full_link, callback = self.parse_link)
def parse_链接(self,response):
打印'llll',response.url
打印'bbbbb',len(response.body),response.body
def解析(自我,响应):
hxs=HtmlXPathSelector(响应)
issues=hxs.select('//a//@id').extract()
对于范围内的i(len(问题)):
问题
links_2d=hxs.select('//html//body//table[%d+%d]/tr/td//a[contains(text(),“full quotes”)]/@href%%(9,i)).extract()
链接\u 2d=列表(设置(链接\u 2d))
如果len(bb)<1:继续
如果len(links_2d)<1:继续
完整链接=链接2d[0]
生成scrapy.Request(url=full\u链接,回调=self.parse\u链接)
试试这个:

def parse(self, response):
        hxs = HtmlXPathSelector(response)
        issues = hxs.select('//a//@id').extract()
        for i in range(len(issues)):
                issue = issues[i]
                links_2d = hxs.select('//html//body//table[%d+%d]/tr/td//a[contains(text(),"full quotes")]/@href' % (9, i)).extract()
                links_2d = list(set(links_2d))

                if len(bb) < 1: continue
                if len(links_2d) < 1: continue

                full_link = links_2d[0]

                yield scrapy.Request(str(full_link), self.parse_link)

def parse_link(self, response):
        print 'lllll', response.url
        print 'bbbbb', len(response.body), response.body
def解析(self,response):
hxs=HtmlXPathSelector(响应)
issues=hxs.select('//a//@id').extract()
对于范围内的i(len(问题)):
问题
links_2d=hxs.select('//html//body//table[%d+%d]/tr/td//a[contains(text(),“full quotes”)]/@href%%(9,i)).extract()
链接\u 2d=列表(设置(链接\u 2d))
如果len(bb)<1:继续
如果len(links_2d)<1:继续
完整链接=链接2d[0]
生成scrapy.Request(str(完整链接)、self.parse\u链接)
def parse_链接(自我,响应):
打印'llll',response.url
打印'bbbbb',len(response.body),response.body

允许的\u域等。。没有问题。
链接
对象实例化在哪里?对不起。这是我的打字错误,我在这里发布之前清除了代码。url=link应该是url=full\u link。问题是:即使我在请求函数中硬编码了一个链接,也可以说:url=''。仍然无法输入解析链接。打印完整链接时会显示什么?请分享一些日志或其他东西,像这样很难帮助你