support ip_country field

This commit is contained in:
2024-01-23 23:33:55 +01:00
parent 97c2b9ce8c
commit aa26e17e99
12 changed files with 147 additions and 60 deletions
+15 -14
View File
@@ -13,12 +13,13 @@ DVM_LIST = [2, 3, 4, 6]
class CookiesGenerator(threading.Thread):
def __init__(self, cookiesPublisher: CookiesPublisher):
def __init__(self, proxy_to_use_list: list, cookiesPublisher: CookiesPublisher):
super().__init__()
self.connection = None
self.cookiesPublisher = cookiesPublisher
self.channel = None
self.valid_csrf = None
self.proxy_to_use_list = proxy_to_use_list
def set_up_connection(self):
self.connection = pika.BlockingConnection(
@@ -40,22 +41,25 @@ class CookiesGenerator(threading.Thread):
# generate 10 cookies to new_queue
captchaResultGetter = CaptchaResultGetter()
_cookies_count = random.randint(2, 10)
_cookies_count = random.randint(8, 10)
_received_cookies = body.decode("UTF-8")
dvm = random.choice(DVM_LIST)
hc = random.choice(DVM_LIST)
if _message_count < 10:
_proxy_to_use = random.choice(self.proxy_to_use_list)
for i in range(1, _cookies_count):
new_cookie = captchaResultGetter.get_valid_ch_cookie(dvm=dvm, hc=hc)
# new_cookie = captchaResultGetter.get_valid_ch_cookie(proxy_to_use=_proxy_to_use, dvm=dvm, hc=hc)
_app_sig = get_app_and_app_sig(_received_cookies)
if new_cookie is not None and _app_sig is not None:
new_cookie = _app_sig + "policy=accepted;lang=fr;" + new_cookie
new_cookie = new_cookie.replace("Domain=.hermes.com;", "").replace("Path=/;", "").replace(
"Secure; SameSite=None", "").replace("Max-Age=31536000;", "").replace(" ", "")
print("new_cookie is " + new_cookie)
_received_cookies = new_cookie
self.cookiesPublisher.publish_body(new_cookie)
new_cookie = captchaResultGetter.get_valid_cookie(new_cookie, dvm=dvm, hc=hc)
# if new_cookie is not None and _app_sig is not None:
# new_cookie = _app_sig + "policy=accepted;lang=fr;" + new_cookie
# new_cookie = new_cookie.replace("Domain=.hermes.com;", "").replace("Path=/;", "").replace(
# "Secure; SameSite=None", "").replace("Max-Age=31536000;", "").replace(" ", "")
# print("new_cookie is " + new_cookie)
# _received_cookies = new_cookie
# self.cookiesPublisher.publish_body(new_cookie)
new_cookie = captchaResultGetter.get_valid_cookie(proxy_to_use=_proxy_to_use,
old_valid_cookie=_received_cookies, dvm=dvm,
hc=hc)
if new_cookie is not None and _app_sig is not None:
new_cookie = _app_sig + "policy=accepted;lang=fr;" + new_cookie
new_cookie = new_cookie.replace("Domain=.hermes.com;", "").replace("Path=/;", "").replace(
@@ -86,9 +90,6 @@ def get_app_and_app_sig(cookies: str):
if __name__ == '__main__':
# _list = get_app_and_app_sig(
# "app.sig=axk5aJ2c83dgV56DswNhw98y4SY;datadome=2dTtQDIHCadAbzh8JWv7MFKGH8~fkOoGlA1O3J7llv_sdYOSZYbaKruHPBbARchV1nnrstsaMX5E_XwbJmGiXzt5qZXOL0UCAV9TTHqBRh10JvO~GCGJv2JVO~6RnrcU;app=eyJmbGFzaCI6e30sImNhY2hlZmxhc2giOltdLCJjc3JmU2VjcmV0IjoiZEE2bEdnN04yd2t0eWVmZmVjVkxMY1dTIiwiYXBwb2ludG1lbnRfY29kZSI6Ik5DTlVaQiIsImJsb2NrX3JlZ2lzdHJhdGlvbiI6ZmFsc2V9;policy=accepted;lang=fr;")
# print(_list)
cookiesPublisher = CookiesPublisher(queue_name=REQUEST_DATA_QUEUE_TEST)
cookiesPublisher.set_up_connection()
cookieGenerator = CookiesGenerator(cookiesPublisher)