【发布时间】:2023-03-11 22:56:01
【问题描述】:
我目前正在使用 Scrapyd 启动爬虫,并且在 Scrapy App 设置中设置了 DEPTH_LIMIT 设置。
我想知道如何在 Scrapyd 中将 depth_limit 作为参数传递,允许我根据用户的要求为每次不同的抓取“动态地”设置它。
我相信我只能作用于 Scrapy 的蜘蛛和管道。
编辑
感谢@John Smith 的回复,我发现可以将设置传递给scrapyd 的schedule 方法
settings = {
'unique_id': unique_id, # unique ID for database instance
'USER_AGENT': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)',
'DEPTH_LIMIT': 1
}
# Schedule a new crawling task from scrapyd
task_id = scrapyd.schedule('default', "spider-name", settings=settings, url=url, domain=domain)
【问题讨论】: