re-queue the safe blocked cookies
This commit is contained in:
@@ -3,6 +3,7 @@ from enum import Enum
|
|||||||
|
|
||||||
class RequestResult(Enum):
|
class RequestResult(Enum):
|
||||||
BLOCKED = "BLOCKED"
|
BLOCKED = "BLOCKED"
|
||||||
|
CSRF_BLOCKED = "CSRF_BLOCKED"
|
||||||
PROXY_ERROR = "PROXY_ERROR"
|
PROXY_ERROR = "PROXY_ERROR"
|
||||||
SUCCESS = "SUCCESS"
|
SUCCESS = "SUCCESS"
|
||||||
COOKIES_ERROR = "COOKIES_ERROR"
|
COOKIES_ERROR = "COOKIES_ERROR"
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class AppointmentRequestSender(threading.Thread):
|
|||||||
captchaResultGetter = CaptchaResultGetter()
|
captchaResultGetter = CaptchaResultGetter()
|
||||||
self.logger.info("contact number is {}".format(len(self.contact_list)))
|
self.logger.info("contact number is {}".format(len(self.contact_list)))
|
||||||
# self.contact_list = filter_contacts(self.contact_list)
|
# self.contact_list = filter_contacts(self.contact_list)
|
||||||
|
can_continue = None
|
||||||
for con in self.contact_list:
|
for con in self.contact_list:
|
||||||
# _proxy_to_use = self.proxy_manager.get_proxy_for_appointment_request()
|
# _proxy_to_use = self.proxy_manager.get_proxy_for_appointment_request()
|
||||||
# print(_proxy_to_use)
|
# print(_proxy_to_use)
|
||||||
@@ -133,6 +134,7 @@ class AppointmentRequestSender(threading.Thread):
|
|||||||
else:
|
else:
|
||||||
self.logger.info("csrf is {}".format(csrf_result))
|
self.logger.info("csrf is {}".format(csrf_result))
|
||||||
if csrf_result == RequestResult.BLOCKED:
|
if csrf_result == RequestResult.BLOCKED:
|
||||||
|
can_continue = RequestResult.CSRF_BLOCKED
|
||||||
break
|
break
|
||||||
_new_cookies = captchaResultGetter.get_valid_ch_cookie(sender.proxy_to_use, js_data,
|
_new_cookies = captchaResultGetter.get_valid_ch_cookie(sender.proxy_to_use, js_data,
|
||||||
old_valid_cookie=_received_cookies)
|
old_valid_cookie=_received_cookies)
|
||||||
@@ -200,6 +202,11 @@ class AppointmentRequestSender(threading.Thread):
|
|||||||
self.valid_csrf = None
|
self.valid_csrf = None
|
||||||
time.sleep(random.randint(1, 2))
|
time.sleep(random.randint(1, 2))
|
||||||
self.logger.info("will ack method.delivery_tag: " + str(method.delivery_tag))
|
self.logger.info("will ack method.delivery_tag: " + str(method.delivery_tag))
|
||||||
|
if can_continue is not None and can_continue == RequestResult.CSRF_BLOCKED:
|
||||||
|
self.logger.info("csrf blocked, will republish cookie")
|
||||||
|
self.cookiesPublisher.publish_body(_received_object)
|
||||||
|
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||||
|
else:
|
||||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||||
else:
|
else:
|
||||||
self.retrieve_invalidate_urls()
|
self.retrieve_invalidate_urls()
|
||||||
|
|||||||
Reference in New Issue
Block a user