我在试图爬行时遇到了一个屈服问题。正如您在下面看到的,我使用了Scrapy并定义了一个Basespider。第一个解析器工作得非常好,并返回在start\u url上找到的所有品牌。在
现在,当我想将回调请求交给categories解析器时,既没有得到响应也没有错误。蜘蛛就不干了。在
蜘蛛:
class brandintrend(BaseSpider):
name = "brandintrend"
allowed_domains = [ 'trend-in-brand.ru' ]
start_urls = [ 'http://brand-in-trend.ru/brands/' ]
def parse(self, response):
hxs = HtmlXPathSelector(response)
brands = hxs.select('//div[@class="brandcol"]/ul/li/a/@href').extract()
for brand in brands:
brand = "http://www.brand-in-trend.ru" + brand
print brand
# request = Request(brand, callback=self.categories)
yield Request(brand, callback=self.categories)
def categories(self, response):
print "Hello World"
hxs = HtmlXPathSelector(response)
print response.url
我已经尝试了以下方法来解决这个问题:
如果有人遇到类似的问题,我将非常乐意为您提供解决方案或建议
提前谢谢
J
这是因为您设置了:
但是,您正在从其他域爬网url:
^{pr2}$请参见
trend-in-brand
与brand-in-trend
。在相关问题 更多 >
编程相关推荐