Python 添加了刮擦规则,但未刮擦更多项目
在我的Scrapy输出文件中,我发现缺少一些项,所以我手动添加这些缺少的页面作为第三条规则Python 添加了刮擦规则,但未刮擦更多项目,python,scrapy,Python,Scrapy,在我的Scrapy输出文件中,我发现缺少一些项,所以我手动添加这些缺少的页面作为第三条规则 class KjvSpider(CrawlSpider): name = 'kjv' start_urls = ['file:///G:/OEBPS2/bible-toc.xhtml'] rules = ( Rule(LinkExtractor(allow=r'OEBPS'), follow=True), # 1st rule Rule
class KjvSpider(CrawlSpider):
name = 'kjv'
start_urls = ['file:///G:/OEBPS2/bible-toc.xhtml']
rules = (
Rule(LinkExtractor(allow=r'OEBPS'), follow=True), # 1st rule
Rule(LinkExtractor(allow=r'\d\.xhtml$'),
callback='parse_item', follow=False), # 2nd rule
Rule(LinkExtractor(allow=[r'2-jn.xhtml$', r'jude.xhtml$', r'obad.xhtml$', r'philem.xhtml$'], ),
callback='parse_item', follow=False), # 3rd rule
)
如果我启用1st rule
和3rd rule
(注释掉2nd rule
),我可以正确下载四个缺少的项目,但不能下载全部项目(大约2000个itmes)
但是如果我启用了这三条规则,那么丢失的项目仍然丢失。(即,如果我添加第三条规则
,则没有区别)
我不知道为什么规则不起作用
欢迎提出任何建议。提前感谢。我想我必须在
第一条规则中拒绝这些缺失的URL,这样在第三条规则中,它就不会被过滤为重复请求。
因此,它将是正常的
e、 g
rules = (
Rule(LinkExtractor(allow=r'OEBPS',deny=(r'2-jn.xhtml$', r'jude.xhtml$',
r'obad.xhtml$',r'philem.xhtml$')), follow=True), # 1st rule
Rule(LinkExtractor(allow=r'\d\.xhtml$'),
callback='parse_item', follow=False), # 2nd rule
Rule(LinkExtractor(allow=[r'2-jn.xhtml$', r'jude.xhtml$', r'obad.xhtml$', r'philem.xhtml$'], ),
callback='parse_item', follow=False), # 3rd rule
)