Пример #1
0
 def process_exception(self, request, exception, spider):
     logger.error(exception)
     login_ok = False
     if ctrl.BEING_LOG is False:
         login_ok = login()
     while ctrl.BEING_LOG:
         time.sleep(1)
     if login_ok:
         self._retry(request, 'unlogin', spider)
Пример #2
0
 def process_response(self, request, response, spider):
     body = response.body_as_unicode()
     if body.find(
             'window.location.href = contextPath +"/portal/uilogin-forwardLogin.shtml";'
     ) != -1 or body.find('访问受限') != -1 or response.status == 404:
         logger.info('未登录,登陆中,请稍后···')
         login_ok = False
         if ctrl.BEING_LOG is False:
             login_ok = login()
         while ctrl.BEING_LOG:
             time.sleep(1)
         if login_ok:
             return self._retry(request, 'unlogin', spider)
     return response