Answer the question
In order to leave comments, you need to log in
Why does it throw an error {"message":"Object reference does not point to an instance of an object.","details":null} when requesting a site via requests python?
I send a request to the site with authorization data. All data is correct, in response I get the following message:
{"message":"Object reference does not point to an instance of an object.","details":null}
import requests, time, json
import hashlib
def md5(s):
return hashlib.md5(s.encode("utf-8")).hexdigest()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.135 YaBrowser/21.6.2.855 Yowser/2.5 Safari/537.36',
'Accept': 'application/json, text/javascript, */*; q=0.01'
}
datas = {
'LoginType': 1,
# 'cid': 2,
# 'sid': ,
# 'pid': 44,
# 'cn': 9,
# 'sft': ,
'scid': 460,
'UN': '123123',
'PW': '123123',
}
s = requests.Session()
start = print(s.get('https://netschool.eduportal44.ru/webapi/logindata').text)
getdata_response = json.loads(s.post('https://netschool.eduportal44.ru/webapi/auth/getdata', headers=headers).text)
datas['lt'] = getdata_response['lt']; datas['salt'] = getdata_response['salt']; datas['ver'] = getdata_response['ver']
time.sleep(1)
datas["pw2"] = md5(datas["salt"]+md5(datas["PW"]))
datas["PW"] = datas['pw2'][0:6]
print(datas["pw2"] + ' || '+datas["PW"])
login = s.post('https://netschool.eduportal44.ru/webapi/login', headers=headers, data=datas)
Answer the question
In order to leave comments, you need to log in
It's decided. By adding a couple of values in the headers, everything started working!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question