add timeout for getting cookies
This commit is contained in:
+19
-13
@@ -38,21 +38,27 @@ def filter_contacts(_contact_list: list) -> list:
|
|||||||
def get_valid_csrf() -> str:
|
def get_valid_csrf() -> str:
|
||||||
captchaResultGetter = CaptchaResultGetter()
|
captchaResultGetter = CaptchaResultGetter()
|
||||||
_valid_cookie = captchaResultGetter.get_valid_cookie()
|
_valid_cookie = captchaResultGetter.get_valid_cookie()
|
||||||
while _valid_cookie is None:
|
# while _valid_cookie is None:
|
||||||
_valid_cookie = captchaResultGetter.get_valid_cookie()
|
# _valid_cookie = captchaResultGetter.get_valid_cookie()
|
||||||
new_csrf = None
|
new_csrf = None
|
||||||
while new_csrf is None:
|
while new_csrf is None:
|
||||||
simple_cookie = SimpleCookie()
|
valid_cookie = None
|
||||||
simple_cookie.load(_valid_cookie)
|
if _valid_cookie is not None:
|
||||||
new_cookies = {k: v.value for k, v in simple_cookie.items()}
|
simple_cookie = SimpleCookie()
|
||||||
new_coolies_str = ""
|
simple_cookie.load(_valid_cookie)
|
||||||
for key in new_cookies:
|
new_cookies = {k: v.value for k, v in simple_cookie.items()}
|
||||||
print(key)
|
new_coolies_str = ""
|
||||||
new_coolies_str = new_coolies_str + key + "=" + new_cookies[key] + ";"
|
for key in new_cookies:
|
||||||
print(new_coolies_str)
|
print(key)
|
||||||
valid_cookie = new_coolies_str + "app=eyJmbGFzaCI6e30sImNhY2hlZmxhc2giOltdLCJjc3JmU2VjcmV0IjoiYnRodHNYU1lvdnl4RzVGakpGRDZsQ0JtIn0=;policy=accepted;lang=fr;"
|
new_coolies_str = new_coolies_str + key + "=" + new_cookies[key] + ";"
|
||||||
|
print(new_coolies_str)
|
||||||
|
valid_cookie = new_coolies_str + "app=eyJmbGFzaCI6e30sImNhY2hlZmxhc2giOltdLCJjc3JmU2VjcmV0IjoiYnRodHNYU1lvdnl4RzVGakpGRDZsQ0JtIn0=;policy=accepted;lang=fr;"
|
||||||
print(valid_cookie)
|
print(valid_cookie)
|
||||||
new_csrf = captchaResultGetter.get_csrf(valid_cookie)
|
new_csrf = captchaResultGetter.get_csrf(valid_cookie)
|
||||||
|
if new_csrf is None:
|
||||||
|
_valid_cookie = None
|
||||||
|
while _valid_cookie is None:
|
||||||
|
_valid_cookie = captchaResultGetter.get_valid_cookie()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return new_csrf
|
return new_csrf
|
||||||
|
|
||||||
@@ -64,7 +70,7 @@ def on_message(ch, method, properties, body):
|
|||||||
global valid_csrf
|
global valid_csrf
|
||||||
print(f" [x] Received {body}")
|
print(f" [x] Received {body}")
|
||||||
sender = Sender(body.decode("UTF-8"))
|
sender = Sender(body.decode("UTF-8"))
|
||||||
contact_list = read_contacts('/Users/panlei/Desktop/yahoo_aol_valid_26-2.xlsx')
|
contact_list = read_contacts('/Users/rdv/Desktop/08_01_24_valid.xlsx')
|
||||||
# remove already booked contacts
|
# remove already booked contacts
|
||||||
sub_contact_list = filter_contacts(contact_list)
|
sub_contact_list = filter_contacts(contact_list)
|
||||||
random.shuffle(sub_contact_list)
|
random.shuffle(sub_contact_list)
|
||||||
@@ -72,7 +78,7 @@ def on_message(ch, method, properties, body):
|
|||||||
for con in sub_contact_list:
|
for con in sub_contact_list:
|
||||||
# if not is_already_sent(con):
|
# if not is_already_sent(con):
|
||||||
print(con.mail)
|
print(con.mail)
|
||||||
time.sleep(random.randint(1, 5))
|
# time.sleep(random.randint(1, 5))
|
||||||
if valid_csrf is None:
|
if valid_csrf is None:
|
||||||
valid_csrf = get_valid_csrf()
|
valid_csrf = get_valid_csrf()
|
||||||
can_continue = sender.send_request(HERMES_REGISTER, con, csrf=valid_csrf)
|
can_continue = sender.send_request(HERMES_REGISTER, con, csrf=valid_csrf)
|
||||||
|
|||||||
Reference in New Issue
Block a user