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