需求是这样,我把所有的url存在了mongo库,想每天查一遍url,抓一遍数据,可是周末并没有执行,
这个项目的日志
项目配置是这样的,我修改过几次itag,让项目重跑,别的项目也遇到几天不跑
@every(minutes=10) def on_start(self): """运行入口""" self.crawl('data:, on_crawl_A', callback=self.crawl_A) @config(age=60,priority=3) def crawl_A(self, response): for page in range(1, 549): params = { 'page_index': page, 'size': self.PAGE_SIZE, 'source': 'aaa', } self.crawl(self.DATA_SERVICE_URL, params=params, callback=self.query_local_api, timeout=60, proxy=False) @config(age=2 * 60,priority=3) def query_local_api(self, response): data = json.loads(response.text) if data['msg'] != 'Success': return urls = [url for url in data['body'] if url.startswith("http://")] print 'urls len------>{}'.format(len(urls)) for url in urls: self.crawl(url, callback=self.detail_page) @config(age=3 * 60 * 60,priority=10) def detail_page(self, response):
其中query_local_api 是查询本地mongo接口返回url,其实我想这样配置
@config(age=24 * 60 * 60,priority=10) def detail_page(self, response):
但是发现这个age怎么配都感觉抓的不对,我理解问题?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
其实可以退一步看, 这个问题是可以利用*nix系统自带的crontab计划任务搞定的