can exchange cookies
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import datetime
|
||||
import json
|
||||
import random
|
||||
import threading
|
||||
import time
|
||||
@@ -8,6 +9,7 @@ import pika
|
||||
|
||||
from db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from models.contact_pojo import ContactPojo
|
||||
from models.jsdata_pojo import JsDataPojo
|
||||
from models.result_pojo import RequestResult
|
||||
from queue_message.CookiesPublisher import CookiesPublisher
|
||||
from utiles import is_time_between
|
||||
@@ -97,52 +99,67 @@ class AppointmentRequestSender(threading.Thread):
|
||||
self.channel.start_consuming()
|
||||
|
||||
def on_message(self, ch, method, properties, body):
|
||||
print(f" [x] Received {body}")
|
||||
_message_count = self.cookiesPublisher.message_count()
|
||||
print("message count in queue is {}".format(_message_count))
|
||||
_received_cookies = body.decode("UTF-8")
|
||||
sender = Sender(_received_cookies, cookiesPublisher=self.cookiesPublisher,
|
||||
proxy_to_use=random.choice(self.proxy_to_use_list))
|
||||
self.contact_list = filter_contacts(self.contact_list)
|
||||
# remove already booked contacts
|
||||
random.shuffle(self.contact_list)
|
||||
if len(self.contact_list) > 0 and is_open() and _message_count > 5:
|
||||
captchaResultGetter = CaptchaResultGetter()
|
||||
print("contact number is {}".format(len(self.contact_list)))
|
||||
_received_object = body.decode("UTF-8")
|
||||
print(f" [x] Received {_received_object}")
|
||||
if "glrd" in _received_object:
|
||||
_received_dict = json.loads(_received_object)
|
||||
js_data = JsDataPojo(glrd=_received_dict['glrd'], glvd=_received_dict['glvd'], hc=_received_dict['hc'],
|
||||
ua=_received_dict['ua'], br_oh=_received_dict['br_oh'], br_ow=_received_dict['br_ow'],
|
||||
ars_h=_received_dict['ars_h'], ars_w=_received_dict['ars_w'], pr=_received_dict['pr'],
|
||||
plg=_received_dict['plg'], br_h=_received_dict['br_h'], br_w=_received_dict['br_w'],
|
||||
plu=_received_dict['plu'], vnd=_received_dict['vnd'], dvm=_received_dict['dvm'],
|
||||
ts_mtp=_received_dict['ts_mtp'], eva=_received_dict['eva'],
|
||||
rs_h=_received_dict['rs_h'],
|
||||
rs_w=_received_dict['rs_w'], rs_cd=_received_dict['rs_cd'])
|
||||
_received_cookies = _received_dict["cookiesStr"]
|
||||
sender = Sender(_received_cookies, cookiesPublisher=self.cookiesPublisher, received_dict=_received_dict,
|
||||
proxy_to_use=random.choice(self.proxy_to_use_list))
|
||||
self.contact_list = filter_contacts(self.contact_list)
|
||||
for con in self.contact_list:
|
||||
# if not is_already_sent(con):
|
||||
print(con.mail)
|
||||
# time.sleep(random.randint(1, 5))
|
||||
if self.valid_csrf is None:
|
||||
self.valid_csrf = captchaResultGetter.get_csrf(proxy_to_use=random.choice(self.proxy_to_use_list),
|
||||
cookie=body.decode("UTF-8"))
|
||||
_new_cookies = captchaResultGetter.get_valid_ch_cookie(sender.proxy_to_use,
|
||||
old_valid_cookie=_received_cookies)
|
||||
if _new_cookies is not None:
|
||||
print("new cookie is " + _new_cookies)
|
||||
sender.cookie_str = _new_cookies
|
||||
can_continue = sender.send_request(HERMES_REGISTER, con, csrf=self.valid_csrf)
|
||||
else:
|
||||
can_continue = RequestResult.COOKIES_ERROR
|
||||
if can_continue == RequestResult.BLOCKED:
|
||||
print("cannot continue, valid_csrf is " + str(self.valid_csrf))
|
||||
break
|
||||
elif can_continue == RequestResult.PROXY_ERROR:
|
||||
print("PROXY_ERROR, will not reset valid_csrf")
|
||||
elif can_continue == RequestResult.COOKIES_ERROR:
|
||||
print("COOKIES_ERROR, will not reset valid_csrf")
|
||||
else:
|
||||
print("can continue, will reset valid_csrf")
|
||||
self.valid_csrf = None
|
||||
# else:
|
||||
# print(con.mail + "--> skip")
|
||||
time.sleep(random.randint(1, 2))
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
# remove already booked contacts
|
||||
random.shuffle(self.contact_list)
|
||||
if len(self.contact_list) > 0 and is_open():
|
||||
captchaResultGetter = CaptchaResultGetter()
|
||||
print("contact number is {}".format(len(self.contact_list)))
|
||||
self.contact_list = filter_contacts(self.contact_list)
|
||||
for con in self.contact_list:
|
||||
# if not is_already_sent(con):
|
||||
print(con.mail)
|
||||
# time.sleep(random.randint(1, 5))
|
||||
if self.valid_csrf is None:
|
||||
self.valid_csrf = captchaResultGetter.get_csrf(
|
||||
proxy_to_use=random.choice(self.proxy_to_use_list),
|
||||
cookie=body.decode("UTF-8"))
|
||||
_new_cookies = captchaResultGetter.get_valid_ch_cookie(sender.proxy_to_use, js_data,
|
||||
old_valid_cookie=_received_cookies)
|
||||
if _received_cookies is not None:
|
||||
print("new cookie is " + _received_cookies)
|
||||
sender.cookie_str = _received_cookies
|
||||
can_continue = sender.send_request(HERMES_REGISTER, con, csrf=self.valid_csrf)
|
||||
else:
|
||||
can_continue = RequestResult.COOKIES_ERROR
|
||||
if can_continue == RequestResult.BLOCKED:
|
||||
print("cannot continue, valid_csrf is " + str(self.valid_csrf))
|
||||
break
|
||||
elif can_continue == RequestResult.PROXY_ERROR:
|
||||
print("PROXY_ERROR, will not reset valid_csrf")
|
||||
elif can_continue == RequestResult.COOKIES_ERROR:
|
||||
print("COOKIES_ERROR, will not reset valid_csrf")
|
||||
else:
|
||||
print("can continue, will reset valid_csrf")
|
||||
self.valid_csrf = None
|
||||
time.sleep(random.randint(1, 2))
|
||||
print("will ack method.delivery_tag: " + str(method.delivery_tag))
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
else:
|
||||
print("empty list")
|
||||
time.sleep(120)
|
||||
print("will basic_reject method.delivery_tag: " + str(method.delivery_tag))
|
||||
ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True)
|
||||
else:
|
||||
print("empty list")
|
||||
time.sleep(120)
|
||||
ch.basic_reject(delivery_tag=method.delivery_tag, requeue=True)
|
||||
print("not a valid object")
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
|
||||
def run(self):
|
||||
print(threading.currentThread().name + " starts")
|
||||
|
||||
Reference in New Issue
Block a user