@timur102

Почему я получаю не тот response?

сайт создает ajax запрос и появляется content.
Request Headers:
Host: ras.arbitr.ru
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: application/json, text/javascript, */*
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://ras.arbitr.ru/
Content-Type: application/json
X-Requested-With: XMLHttpRequest
Content-Length: 158
Cookie: ASP.NET_SessionId=z5vhqqiduz0ayd0vgtjgjmgp; CUID=ffc718f7-a0d5-4ffb-b3c9-4e45d83e772a:M2zwJUhJBS+PcLiGoXAmjg==; rcid=679e185d-3396-446e-9089-df1a992962f2
DNT: 1
Connection: keep-alive

Request Body:
{"GroupByCase":false,"Count":25,"Page":2,"DateFrom":"2000-01-01T00:00:00","DateTo":"2030-01-01T23:59:59","Sides":[],"Judges":[],"Cases":[],"Text":"а46-1/16"}

Получаю нормальный json ответ.
Но как только я пытаюсь реализовать тоже самое на python
<br>
import requests<br>
data = {"GroupByCase":False,"Count":25,"Page":1,"DateFrom":"2000-01-01T00:00:00","DateTo":"2030-01-01T23:59:59","Sides":[],"Judges":[],"Cases":[],"Text":"а46-1/16"}<br>
headers = {"Host": "ras.arbitr.ru", "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0", "Accept": "application/json, text/javascript, */*", "Accept-Language": "en-GB,en;q=0.5", "Accept-Encoding": "gzip, deflate", "Referer": "http://ras.arbitr.ru/", "Content-Type": "application/json", "X-Requested-With":"XMLHttpRequest", "Content-Length": 158, "Cookie": "ASP.NET_SessionId=inuzdzsqv0xs5qt310avvfvj; CUID=489f2c18-a4f6-4f6b-a4ed-488670106512:IiOT7HF6x4O/ZLqZjB3NJQ==; _ga=GA1.2.1749882841.1531051745; _gid=GA1.2.1216957755.1531051745; rcid=521dbbe4-d482-43b1-bc86-ff1eb51bb2ad; _gat=1", "Connection": "keep-alive"}<br>
r =requests.post('http://ras.arbitr.ru/Ras/Search',data = data, headers = headers)<br>

то получаю такой ответ

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru"><head>
	<title>Ведутся технические работы</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
	<meta name="viewport" content="width=device-width">
	<meta http-equiv="Content-Language" content="ru_RU">

	<meta http-equiv="Content-Script-Type" content="text/javascript">
	<meta http-equiv="Content-Style-Type" content="text/css">

	<meta http-equiv="expires" content="Mon, 26 Jul 1997 05:00:00 GMT">

	<link rel="home" href="/">
	<link rel="icon" type="image/png" href="/favicon.ico">

    <!--link rel="stylesheet" type="text/css" href="/Content/Static/css/pages/stub.css"-->
    <style>
        html{
	height: 100%;
	width: 100%;
}
body{
	padding: 0;
	margin: 0;
	background: #e4eaef;
	height: 100%;
	width: 100%;
	font-family: arial;
}
.b-container{
	height: 100%;
	margin: 0 auto;
	width: 100%;
	min-height: 468px;
	min-width: 472px;
	padding-top: 50px;
}
.b-offline-name {
	/*background: url(/Content/Static/img/t/gerb_vas.png) no-repeat 50% 0;*/
	width: 200px;
	margin: 0 auto;
	padding-top: 138px;
	color: #828995;
	font-size: 12px;
	text-shadow: 0 1px #FFFEFA;
	text-align: center;
}
.b-offline-content {
	margin: 50px 0 0;
	color: #383C45;
	text-align: center;
	font-size: 20px;
}
    </style>
</head>
<body>
	<div class="b-container">
		<div class="b-offline-name">
			Электронное правосудие
		</div>
		<div class="b-offline-content">
			Приносим извинения,<br />
			ведутся профилактические работы.<br />
			Сервис временно недоступен.
		</div>
	</div>
</body></html>

Почему так происходит? Можно ли это обойти?
  • Вопрос задан
  • 140 просмотров
Решения вопроса 1
BuriK666
@BuriK666
Компьютерный псих
r = requests.post('http://ras.arbitr.ru/Ras/Search', json=data, headers=headers)
docs.python-requests.org/en/master/user/quickstart...
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы