Во-первых, вы должны проверить правильный http-запрос в браузере.
POST https://www.amundi-ee.com/psf/authenticate HTTP/1.1
Host: www.amundi-ee.com
Connection: keep-alive
Content-Length: 35
Accept: application/json, text/plain, */*
Origin: https://www.amundi-ee.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
DNT: 1
Content-Type: application/json;charset=UTF-8
Referer: https://www.amundi-ee.com/psf/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7
Cookie: EXCV-20480=ODCBPNAKFAAA; TCPID=1181011512189835414503; xtvrn=$566107$; xtan=-; xtant=1
{"username":"313","password":"730"}
Во-вторых, запрос на сборку такой же, как и он.
Изменение: после теста код состояния ответа сервера будет 400 и произнесено:Ошибка данных JSON.Затем я изменяю свой код, отправляю данные как json.Когда этот код состояния времени равен 403. То же самое, что и я, неудачно вошел в браузер.
import requests,time,lxml
import json
url = "https://www.amundi-ee.com/psf/"
LOGIN = "https://www.amundi-ee.com/psf/authenticate"
PROTECTED_PAGE = "https://www.amundi-ee.com/psf/#avoirs"
payload = {"username":"000000","password":"111111",}
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36",
"Referer":"https://www.amundi-ee.com/psf/",
"Accept-Encoding": "gzip, deflate, br",
"Content-Type": "application/json;charset=UTF-8",
"DNT": "1",
"Accept": "application/json, text/plain, */*",
"Origin": "https://www.amundi-ee.com"}
with requests.session() as s:
req = s.post(LOGIN, headers=headers, json=json.loads(json.dumps(payload)) )
time.sleep(2)
f = s.get(PROTECTED_PAGE,cookies = req.cookies , headers = headers)
Запрос:
POST https://www.amundi-ee.com/psf/authenticate HTTP/1.1
Host: www.amundi-ee.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Referer: https://www.amundi-ee.com/psf/
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7
Origin: https://www.amundi-ee.com
DNT: 1
Content-Type: application/json;charset=UTF-8
Content-Length: 44
{"username": "000000", "password": "111111"}