|
|
@@ -47,20 +47,24 @@ class ProxyRefreshSchedule(ProxyManager):
|
|
|
"""
|
|
|
self.db.changeTable(self.raw_proxy_queue)
|
|
|
raw_proxy = self.db.pop()
|
|
|
- self.log.info('%s start validProxy_a' % time.ctime())
|
|
|
+ self.log.info('ProxyRefreshSchedule: %s start validProxy' % time.ctime())
|
|
|
# 计算剩余代理,用来减少重复计算
|
|
|
remaining_proxies = self.db.getAll()
|
|
|
while raw_proxy:
|
|
|
+ if isinstance(raw_proxy, bytes):
|
|
|
+ # 兼容Py3
|
|
|
+ raw_proxy = raw_proxy.decode('utf8')
|
|
|
+
|
|
|
if (raw_proxy not in remaining_proxies) and validUsefulProxy(raw_proxy):
|
|
|
self.db.changeTable(self.useful_proxy_queue)
|
|
|
self.db.put(raw_proxy)
|
|
|
- self.log.info('validProxy_a: %s validation pass' % raw_proxy)
|
|
|
+ self.log.info('ProxyRefreshSchedule: %s validation pass' % raw_proxy)
|
|
|
else:
|
|
|
- self.log.debug('validProxy_a: %s validation fail' % raw_proxy)
|
|
|
+ self.log.info('ProxyRefreshSchedule: %s validation fail' % raw_proxy)
|
|
|
self.db.changeTable(self.raw_proxy_queue)
|
|
|
raw_proxy = self.db.pop()
|
|
|
remaining_proxies = self.db.getAll()
|
|
|
- self.log.info('%s validProxy_a complete' % time.ctime())
|
|
|
+ self.log.info('ProxyRefreshSchedule: %s validProxy complete' % time.ctime())
|
|
|
|
|
|
|
|
|
def refreshPool():
|
|
|
@@ -88,9 +92,9 @@ def main(process_num=30):
|
|
|
|
|
|
|
|
|
def run():
|
|
|
- # main()
|
|
|
+ main()
|
|
|
sched = BlockingScheduler()
|
|
|
- sched.add_job(main, 'interval', minutes=5)
|
|
|
+ sched.add_job(main, 'interval', minutes=10) # 每10分钟抓取一次
|
|
|
sched.start()
|
|
|
|
|
|
|