get csrf before send request

This commit is contained in:
2024-01-11 13:22:32 +01:00
parent 8b4a895cfb
commit 8063218514
4 changed files with 185 additions and 22 deletions
+7 -3
View File
@@ -39,8 +39,11 @@ class Sender:
def get_csrf(self):
pass
def send_request(self, url, contact: ContactPojo):
csrf = '5tHIY0Tf-AEKRQB7dbM7-_OIh7pZG_HdLsAk'
def send_request(self, url, contact: ContactPojo, csrf: str = None):
if csrf is None:
_csrf = '5tHIY0Tf-AEKRQB7dbM7-_OIh7pZG_HdLsAk'
else:
_csrf = csrf
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': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8',
@@ -48,13 +51,14 @@ class Sender:
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Dest': 'document',
'Accept-Language': 'fr-FR,fr;q=0.6'}
data = {'check': '', '_csrf': csrf, 'prefer': '',
data = {'check': '', '_csrf': _csrf, 'prefer': '',
'surname': contact.last_name.capitalize(), 'name': contact.first_name.capitalize(),
'phone_country': "FR", 'phone_number': contact.phone, 'email': contact.mail,
'passport_id': contact.passport, 'processing': 'on', 'cgu': 'on'}
print(data)
try:
proxy_to_use = random.choice(PROXY_LIST)
# proxy_to_use = PROXY_LIST[0]
print(proxy_to_use)
response = requests.post(url=url, proxies=proxy_to_use, verify=False, headers=headers, data=data,
timeout=15)