Scrapy没有抓取所有页面

Sid*_*rth 4 python scrapy

我试图以非常基本的方式抓取网站.但Scrapy没有抓取所有链接.我会解释如下情况─

main_page.html - >包含指向a_page.html,b_page.html,c_page.html的
链接a_page.html - >包含指向a1_page.html的链接,a2_page.html
b_page.html - >包含指向b1_page.html,b2_page.html
c_page的链接.html - >包含指向c1_page.html的链接,c2_page.html
a1_page.html - >包含指向b_page.html的链接
a2_page.html - >包含指向c_page.html的链接
b1_page.html - >包含指向a_page.html的链接
b2_page.html - >包含指向c_page.html的链接
c1_page.html - >包含指向a_page.html的链接
c2_page.html - >包含指向main_page.html的链接

我在CrawlSpider中使用以下规则 -

Rule(SgmlLinkExtractor(allow = ()), callback = 'parse_item', follow = True))

但抓取结果如下 -

DEBUG:Crawled(200)http://localhost/main_page.html>(referer:None)2011-12-05 09:56:07 + 0530 [test_spider] DEBUG:Crawled(200)http:// localhost/a_page. html>(referer: http://localhost/main_page.html )2011-12-05 09:56:07 + 0530 [test_spider] DEBUG:Crawled(200)http://localhost/a1_page.html>(referer:http ://localhost/a_page.html )2011-12-05 09:56:07 + 0530 [test_spider] DEBUG:Crawled(200)http://localhost/b_page.html>(referer:http:// localhost/a1_page .html)2011-12-05 09:56:07 + 0530 [test_spider] DEBUG:Crawled(200)http://localhost/b1_page.html>(referer:http://localhost/b_page.html)2011-12 -05 09:56:07 + 0530 [test_spider]信息:关闭蜘蛛(已完成)

它没有抓取所有页面.

注意 - 我已经在Scrapy Doc中指出了BFO中的爬行.

我错过了什么?

Sja*_*aak 5

默认情况下,Scrapy会过滤掉所有重复的请求.

您可以通过使用(示例)来避免这种情况:

yield Request(url="test.com", callback=self.callback, dont_filter = True)
Run Code Online (Sandbox Code Playgroud)

dont_filter(boolean) - 表示调度程序不应过滤此请求.当您想要多次执行相同的请求时,可以使用此选项来忽略重复过滤器.小心使用它,否则您将进入爬行循环.默认为False.

另请参阅Request对象文档