share cookies with click link programme when blocked.

This commit is contained in:
Lei PAN
2024-07-03 16:38:03 +02:00
parent 26792dd310
commit 801df9b06a
2 changed files with 16 additions and 4 deletions
@@ -64,12 +64,14 @@ def is_open():
class AppointmentRequestSender(threading.Thread):
def __init__(self, sub_contact_list: list, logger, cookiesPublisher: CookiesPublisher,
bakeUpCookiesPublisher: CookiesPublisher,
queue_name=REQUEST_DATA_QUEUE):
super().__init__()
self.connection = None
self.logger = logger
self.already_tried_contact_list = []
self.cookiesPublisher = cookiesPublisher
self.bakeUpCookiesPublisher = bakeUpCookiesPublisher
self.channel = None
self.valid_csrf = None
self.list_to_retrieve_mails = sub_contact_list
@@ -203,8 +205,15 @@ class AppointmentRequestSender(threading.Thread):
time.sleep(random.randint(1, 2))
self.logger.info("will ack method.delivery_tag: " + str(method.delivery_tag))
if can_continue is not None and can_continue == RequestResult.CSRF_BLOCKED:
# 如果在发送请求时出现csrf被拦截的情况,那么就需要重新发布cookie以目前的队列中,因为这个cookie可能重新利用
self.logger.info("csrf blocked, will republish cookie")
self.cookiesPublisher.publish_body(_received_object)
self.logger.info("csrf blocked, will wait 60 seconds")
time.sleep(60)
ch.basic_ack(delivery_tag=method.delivery_tag)
elif can_continue is not None and can_continue == RequestResult.BLOCKED:
self.logger.info("这个cookies可以给点链接用")
self.bakeUpCookiesPublisher.publish_body(_received_object)
ch.basic_ack(delivery_tag=method.delivery_tag)
else:
ch.basic_ack(delivery_tag=method.delivery_tag)