需求是这样,我把所有的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怎么配都感觉抓的不对,我理解问题?
Your code is inconsistent with the picture you posted. The code is run every 10 minutes, but the picture above is 6 hours
Just find a task that you think should be included, get the taskid on the debug page (it’s in the json on the upper left), and go to the /task/project:taskid page to check its current status
I am currently studying how to write scheduled tasks in Python. You may consider using apscheduler
In fact, you can take a step back and look at it. This problem can be solved by using
*nix
系统自带的crontab
planned tasksGuess:
Could it be because the decorator you wrote is not handled correctly?
Now I am studying to write a crawler in PHP