我不熟悉Scrapy,刚成功抓取了一个页面,在寻找120个可用结果时检索了58个结果。
问题似乎是,如果一个网站包含4个链接,则scrapy跟随第一个,而其他三个将永远不会被访问,因为指向这些页面的链接仅位于该页面中,并且将不再被访问。我假设这样做是因为在结果集中缺少这3个,但是如果我在浏览器中访问该页面,链接就可以了。
蜘蛛:
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
#CLOSESPIDER_PAGECOUNT=1
from bid.items import riegerItem
class GetbidSpider(CrawlSpider):
name = 'example'
allowed_domains = ['www.example.co.uk']
start_urls = ['https://www.example.co.uk/']
rules = (
Rule(
LinkExtractor(allow=['test/.*,item,.*u']),
callback='parse_item'
),
# follow all urls in beta folder that are not schmuck
Rule(
LinkExtractor(allow=['test/[^dismiss|this].*']),
follow=True
),
)
...
输出:
{'downloader/request_bytes': 31681,
'downloader/request_count': 101,
'downloader/request_method_count/GET': 101,
'downloader/response_bytes': 1129752,
'downloader/response_count': 101,
'downloader/response_status_count/200': 101,
'dupefilter/filtered': 746,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2018, 11, 22, 23, 0, 30, 937420),
'item_scraped_count': 58,
'log_count/DEBUG': 161,
'log_count/INFO': 8,
'memusage/max': 49242112,
'memusage/startup': 49242112,
'request_depth_max': 4,
'response_received_count': 101,
'scheduler/dequeued': 100,
'scheduler/dequeued/memory': 100,
'scheduler/enqueued': 100,
'scheduler/enqueued/memory': 100,
'start_time': datetime.datetime(2018, 11, 22, 23, 0, 26, 78036)}
2018-11-23 00:00:30 [scrapy.core.engine] INFO: Spider closed (finished)
我正在使用模板蜘蛛中的默认设置。
如果我再次运行它,将会获取其他少量金额
如何调试此问题以便检索所有结果?
答案 0 :(得分:0)
发现了问题。具有第二条规则的正则表达式禁止使用这些URL。在正则表达式上工作,但不能正常运行。