我正在尝试使用 Scrapy 制作递归解析脚本,但Request()
函数不调用回调函数suppose_to_parse()
,也不调用回调值中提供的任何函数。我尝试了不同的变体,但它们都不起作用。去哪里挖?
from scrapy.http import Request
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
class joomler(BaseSpider):
name = "scrapy"
allowed_domains = ["scrapy.org"]
start_urls = ["http://blog.scrapy.org/"]
def parse(self, response):
print "Working... "+response.url
hxs = HtmlXPathSelector(response)
for link in hxs.select('//a/@href').extract():
if not link.startswith('http://') and not link.startswith('#'):
url=""
url=(self.start_urls[0]+link).replace('//','/')
print url
yield Request(url, callback=self.suppose_to_parse)
def suppose_to_parse(self, response):
print "asdasd"
print response.url