def __init__(self, host, port, api_key, api_secret, per_token_hours_limit, per_ip_hours_limit, buffer_size, ip_address): r = _default_redis(host, port) self.req_count = _v1_req_count(r, api_key=api_key, api_secret=api_secret) self.req_ip_count = _ip_req_count(r) self.localIp = ip_address self.tk_alive = _v1_tk_alive(r, api_key=api_key, api_secret=api_secret) self.per_token_hours_limit = per_token_hours_limit self.per_ip_hours_limit = per_ip_hours_limit self.buffer_size = buffer_size self.api_key = api_key self.api_secret = api_secret
# -*- coding: utf-8 -*- from tk_maintain import reset_ip_req_count, _ip_req_count, _default_redis r = _default_redis() req_ip_count = _ip_req_count(r) reset_ip_req_count(req_ip_count) # windows cron jobs # schtasks /create /sc hourly /st 00:00:00 /tn PythonIpResetCountTask /TR "C:\python27\python.exe E:\scrapy_weibo_v1\install\utils4scrapy-master\utils4scrapy\auto_reset_ip_count.py" # schtasks /delete /tn PythonIpResetCountTask # linux cron jobs # cd /etc/crontab; # vim /etc/crontab; # 0 * * * * root cd /home/mirage/linhao/scrapy_weibo/install/utils4scrapy-master/utils4scrapy;python auto_reset_ip_req_count.py