There is a website where I need to log in
requests with authorization are sent to https://auth.dikidi.ru/ajax/check/auth/
This is my code:
import requests
with requests.Session() as session:
url = 'https://auth.dikidi.ru/ajax/check/auth/'
data = {
'number': 'number',
'password': 'password'
}
response = session.post(url, data=data)
print(response.text)
if I send a request with an incorrect number, I get a response in JSON format:
data = {
'number': 'wrong number',
'password': 'password'
}
the following response comes:
{"error":{"code":"NUMBER_NOT_TRUE","message":"Probably you entered incorrect number"},"data":{}}
, which is logical
if I send a request from an unregistered number, I get an HTML page code in response:
data = {
'number': 'unregistered number',
'password': 'password'
}
if I send a request with my number, I get in response the code of the HTML page where it says "forgot your password?":
data = {
'number': 'my number',
'password': 'password'
}
Answer: {"container":".modal.auth .pocket","html":"<div class=\"login\" data-perform=\"sw.auth.login(this)\">\n\t<input type=\"hidden\" name=\"csrf\" value=\"303c7a1cd02e773cfc7122e111215802:1747001155.2483\" \/>\n\t<div class=\"form-group\">\n\t\t<label>Password<\/label>\n\t\t<input type=\"password\" name=\"password\" class=\"form-control no-cleaning\" tabindex=\"2\" \/>\n\t\t<a class=\"forgot\">
Forgot your password?<\/a>\n\t<\/div>\n <\/div> \n"}
As I understand it, the number is sent to the server and if the server finds it in the database, it requests a password
How can i login to my account on this site using python and requests? (selenium doesn't work, it won't let me enter my number)
Code using selenium:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Chrome()
driver.get("https://dikidi.ru/en/business")
driver.find_element(By.PARTIAL_LINK_TEXT, "Login / Registration").click()
time.sleep(1)
driver.find_element(By.PARTIAL_LINK_TEXT, "Phone number").click()
time.sleep(1)
number = driver.find_element(By.ID, 'number')
number.send_keys('my number without a country code')
time.sleep(10)
I was able to log into the site only using the token from the cookie
import requests
cookies = {'token': 'MyToken'}
requests.post('https://dikidi.ru', cookies=cookies)