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
+7 -7
View File
@@ -5,7 +5,7 @@ from time import time
from typing import Union
import requests
from workers.proxies_constants import PROXY_LIST
from workers.proxies_constants import PROXY_LIST_FR
API_KEY = "d66aaf490d8aa424a5175e1fbd1aadea"
@@ -21,7 +21,7 @@ class CaptchaResultGetter:
self.cookie_str = 'datadome=5Nq~NEP_qQSHC0g_lZNnZmEv36J8gVV~rpZ329xmCkTq2~H3meIoXr4h_b988qB2XW5Te7iEGsvq8BzA5KeFupyrZFh4kgrDyl8hT2UymSByKHzAcDaNIBPDsRu2g_KG; Max-Age=31536000; Domain=.hermes.com; Path=/; Secure; SameSite=None'
pass
def get_csrf(self, cookie: str = None) -> Union[str, None]:
def get_csrf(self, proxy_to_use, cookie: str = None) -> Union[str, None]:
if cookie is not None:
headers = {'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36',
@@ -39,8 +39,8 @@ class CaptchaResultGetter:
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Dest': 'document',
'Accept-Language': 'fr-FR,fr;q=0.6'}
proxy_to_use = random.choice(PROXY_LIST)
print("received cookie is " + str(cookie))
print(proxy_to_use)
try:
response = requests.get(url=HERMES_REGISTER, headers=headers, verify=False, proxies=proxy_to_use,
timeout=15)
@@ -62,7 +62,7 @@ class CaptchaResultGetter:
return result_list[-1]
return None
def get_valid_cookie(self, old_valid_cookie: str, dvm=4, hc=6) -> Union[str, None]:
def get_valid_cookie(self, proxy_to_use, old_valid_cookie: str, dvm=4, hc=6) -> Union[str, None]:
headers = {'content-Type': 'application/x-www-form-urlencoded',
'user-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36',
'accept': '*/*',
@@ -75,8 +75,8 @@ class CaptchaResultGetter:
'sec-ch-ua-platform': 'Android',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'fr-FR,fr;q=0.6'}
proxy_to_use = random.choice(PROXY_LIST)
print("send request to get new cookie")
print(proxy_to_use)
print(headers)
try:
# tag_pu = 10 * Math.random()
@@ -97,7 +97,7 @@ class CaptchaResultGetter:
print(error)
return None
def get_valid_ch_cookie(self, old_valid_cookie: str = None, dvm=4, hc=6) -> Union[str, None]:
def get_valid_ch_cookie(self, proxy_to_use, old_valid_cookie: str = None, dvm=4, hc=6) -> Union[str, None]:
headers = {'content-Type': 'application/x-www-form-urlencoded',
'user-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Mobile Safari/537.36',
'accept': '*/*',
@@ -109,7 +109,7 @@ class CaptchaResultGetter:
'sec-fetch-dest': 'empty',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'fr-FR,fr;q=0.6'}
proxy_to_use = random.choice(PROXY_LIST)
print(proxy_to_use)
print("send request to get new cookie")
print(headers)
try: