Scrappy规则未获取所有指定链接

2024-10-03 06:32:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我想以以下格式对所有链接进行爬网:

http://example.com/index.php/comments/XXXXX
http://example.com/XXX1/index.php/comments/XXXXX
http://example.com/XXX2/index.php/comments/XXXX
http://example.com/XXX3/index.php/comments/XXXX

我定义了以下规则:

start_urls = ['http://example.com/']

rules = [Rule(SgmlLinkExtractor(allow=[r'\w+/index.php/comments/\w+']), callback='parse_blogpost', follow=True)]

但爬虫似乎只访问了这样的链接(http://example.com/index.php/comments/XXXXX),而没有访问这样的链接(http://example.com/XXX1/index.php/comments/XXXXX)。你知道吗

任何帮助都将不胜感激!你知道吗


Tags: comhttpindex定义链接规则example格式