There is a link: https://cabinet.sut.ru/raspisanie_all_new.php You need to make a request with the selected data from the checkboxes and the pressed button and get the html in which there will be a generated schedule.

import requests url = 'https://cabinet.sut.ru/raspisanie_all_new.php' data = {'schet':'205.1617%2F2','type_z': 1,'faculty': 50007,'group': 52002,'ok':'%CF%EE%EA%E0%E7%E0%F2%FC'} # вот наши данные для POST r = requests.post(url, data=data) #делаю пост запрос с уже запрашиваемыми данными в форме. r.text # вывожу html, <b>но не получаю ЖЕЛАННОЕ РАСПИСАНИЕ, КОТОРОЕ ДОЛЖНО БЫТЬ СФОРМИРОВАНО</b> 

I receive:

 u'<html>\n<head>\n <meta content="text/html; charset=windows-1251" http-equiv="Content-Type"/> \n <META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW"> \n <link rel="stylesheet" type="text/css" href="https://cabinet.sut.ru/css/style.css"/> \n <link href="https://cabinet.sut.ru/css/form.css" rel="stylesheet" type="text/css" /> \n <link media="all" type="text/css" rel="stylesheet" href="https://cabinet.sut.ru/css/table.css"> \n <script type="text/javascript" src="https://cabinet.sut.ru/scripts/jquery.js"></script> \n <title> \xd1\xcf\xe1\xc3\xd3\xd2 - \xd0\xe0\xf1\xef\xe8\xf1\xe0\xed\xe8\xe5</title> \n</head> \n<style>\nbody {\n background: #fff none repeat scroll 0 0;\n font-family: Tahoma,Arial,Helvetica;\n margin: 0;\n padding: 0;\n} \nhr {\n background-image: -moz-linear-gradient(left center , rgba(255, 165, 0, 0.11), rgba(255, 165, 0, 0.75), rgba(255, 165, 0, 0.11));\n border: 0 none;\n height: 2px;\n}\n</style> \n<body id="body" style="background:#fff"> \n<div id="rightpanel" style="background:#fff;width:auto;">\n<form name="frm" method="post" style="text-align: center;width:99%;"> \n\xd3\xf7\xe5\xe1\xed\xfb\xe9 \xe3\xee\xe4 <select id="schet" name="schet" onchange="change_usl();" ><option value=0 >\xed\xe5 \xe2\xfb\xe1\xf0\xe0\xed\xee</option> <option value=205.1718/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 17/18 \xf3\xf7. \xe3.</option> <option value=205.1718/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 17/18 \xf3\xf7. \xe3.</option> <option value=205.1718>2017/2018 \xf3\xf7.\xe3.</option> <option value=205.1617/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 16/17 \xf3\xf7. \xe3.</option> <option value=205.1617/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 16/17 \xf3\xf7. \xe3.</option> <option value=205.1617>2016/2017 \xf3\xf7.\xe3.</option> <option value=205.1516/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 15/16 \xf3\xf7. \xe3.</option> <option value=205.1516/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 15/16 \xf3\xf7. \xe3.</option> <option value=205.1516>2015/2016 \xf3\xf7.\xe3.</option> <option value=205.0405/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 04/05 \xf3\xf7. \xe3.</option> <option value=205.0405/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 04/05 \xf3\xf7. \xe3.</option> <option value=205.0405>2004/2005 \xf3\xf7.\xe3.</option> <option value=205.1112/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 11/12 \xf3\xf7. \xe3.</option> <option value=205.1112/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 11/12 \xf3\xf7. \xe3.</option> <option value=205.1112>2011/2012 \xf3\xf7.\xe3.</option> <option value=205.1213/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 12/13 \xf3\xf7. \xe3.</option> <option value=205.1314/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 13/14 \xf3\xf7. \xe3.</option> <option value=205.1415/1>1 \xf1\xe5\xec\xe5\xf1\xf2\xf0 14/15 \xf3\xf7. \xe3.</option> <option value=205.1213/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 12/13 \xf3\xf7. \xe3.</option> <option value=205.1314/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 13/14 \xf3\xf7. \xe3.</option> <option value=205.1415/2>2 \xf1\xe5\xec\xe5\xf1\xf2\xf0 14/15 \xf3\xf7. \xe3.</option> <option value=205.0809>2008/2009 \xf3\xf7.\xe3.</option> <option value=205.0910>2009/2010 \xf3\xf7.\xe3.</option> <option value=205.1011>2010/2011 \xf3\xf7.\xe3.</option> <option value=205.1213>2012/2013 \xf3\xf7.\xe3.</option> <option value=205.1314>2013/2014 \xf3\xf7.\xe3.</option> <option value=205.1415>2014/2015 \xf3\xf7.\xe3.</option> </select><br/><br/>\xd2\xe8\xef \xf0\xe0\xf1\xef\xe8\xf1\xe0\xed\xe8\xff <select id="type_z" name="type_z" onchange="change_usl();" onchange="change_usl();" ><option value=0 >\xed\xe5 \xe2\xfb\xe1\xf0\xe0\xed\xee</option> <option value=1 selected>\xc7\xe0\xed\xff\xf2\xe8\xff</option> <option value=2>\xdd\xea\xe7\xe0\xec\xe5\xed\xe0\xf6\xe8\xee\xed\xed\xe0\xff \xf1\xe5\xf1\xf1\xe8\xff</option> <option value=3>\xd4\xe0\xea\xf3\xeb\xfc\xf2\xe0\xf2\xe8\xe2\xfb</option> <option value=4>\xd1\xe5\xf1\xf1\xe8\xff \xe4\xeb\xff \xe7\xe0\xee\xf7\xed\xe8\xea\xee\xe2</option> <option value=5>\xc3\xee\xf1\xf3\xe4\xe0\xf0\xf1\xf2\xe2\xe5\xed\xed\xe0\xff \xe8\xf2\xee\xe3\xee\xe2\xe0\xff \xe0\xf2\xf2\xe5\xf1\xf2\xe0\xf6\xe8\xff</option> <option value=6>\xca\xee\xed\xf4\xe5\xf0\xe5\xed\xf6\xe8\xe8 \xe8 \xef\xf0\xee\xf7\xe5\xe5</option> </select><br/><br/>\xd4\xe0\xea\xf3\xeb\xfc\xf2\xe5\xf2 <select id="faculty" name="faculty" onchange="change_fac();" ><option value=0 >\xed\xe5 \xe2\xfb\xe1\xf0\xe0\xed\xee</option> </select><br/><br/>\xc3\xf0\xf3\xef\xef\xe0 <select style="width:130px;" id="group" name="group" onchange="change_group();"><option value=0 >\xed\xe5 \xe2\xfb\xe1\xf0\xe0\xed\xee</option> </select><br/><br/><input type="submit" value="\xcf\xee\xea\xe0\xe7\xe0\xf2\xfc" name="ok"><br/><span id="blok_zach" style="display: block;"><br/>\xd0\xe0\xf1\xef\xe8\xf1\xe0\xed\xe8\xe5 \xe7\xe0\xf7\xe5\xf2\xee\xe2 <input type="submit" value="\xcf\xee\xea\xe0\xe7\xe0\xf2\xfc" name="rasp_zach"><br/><br/></span><span id="blok" style="display: none;">\xd0\xe0\xf1\xef\xe8\xf1\xe0\xed\xe8\xe5 \xe7\xe0\xed\xff\xf2\xe8\xe9 \xe4\xeb\xff \xfd\xeb\xe5\xea\xf2\xe8\xe2\xed\xfb\xf5 \xe3\xf0\xf3\xef\xef. \xc3\xf0\xf3\xef\xef\xe0 <select style="width:130px;" id="group_el" name="group_el" ><option value=0 >\xed\xe5 \xe2\xfb\xe1\xf0\xe0\xed\xee</option> </select> <input type="submit" value="\xcf\xee\xea\xe0\xe7\xe0\xf2\xfc" name="el_ok"></span><p>\xd0\xe0\xf1\xef\xe8\xf1\xe0\xed\xe8\xe5 \xec\xee\xe6\xed\xee \xef\xee\xf1\xec\xee\xf2\xf0\xe5\xf2\xfc \xe2 <a target=\'_BLANK\' href=\'https://cabs.itut.ru/cabinet\'>\xcb\xe8\xf7\xed\xee\xec \xea\xe0\xe1\xe8\xed\xe5\xf2\xe5</a>.</p></form>\xc7\xe0\xed\xff\xf2\xe8\xe9 \xe4\xeb\xff \xe2\xfb\xe1\xf0\xe0\xed\xed\xee\xe9 \xe3\xf0\xf3\xef\xef\xfb \xed\xe5 \xed\xe0\xe9\xe4\xe5\xed\xee</tbody></table><br /> \n </div></div></div> \n<script type="text/javascript"> \n\n function listLoad(data)\n{ document.getElementById(\'blok\').style.display = "none";\n $("select#group").html(\'<option value="">...</option>\'); \n var splits = data.split(\';\'); \n\n for (i=0; i<splits.length-1; i++)\n { var prepareLoad = splits[i];\n var loadData = prepareLoad.split(\',\');\n var insertData = \'<option value="\'+loadData[0]+\'">\'+loadData[1]+\'</option>\';\n $("select#group").append(insertData); \n } \n} \n function listLoad_fac(data)\n{ $("select#faculty").html(\'<option value="">...</option>\'); \n var splits = data.split(\';\'); \n\n for (i=0; i<splits.length-1; i++)\n { var prepareLoad = splits[i];\n var loadData = prepareLoad.split(\',\');\n var insertData = \'<option value="\'+loadData[0]+\'">\'+loadData[1]+\'</option>\';\n $("select#faculty").append(insertData); \n } \n} \n function change_usl()\n { var type = $("#type_z").val(); if (type==0) return;\n var schet = $("#schet").val(); if (schet==0) return; \n \n if (type==1) document.getElementById(\'blok_zach\').style.display = "block";\n else document.getElementById(\'blok_zach\').style.display = "none"; \n \n $.post(\'raspisanie_all_new.php\', {choice:1, type_z: type, schet: schet}, listLoad_fac); \n }\n function change_group()\n { var group = $("#group").val(); \n if (group==52327 || group==52328 || group==52329 || group==52330) document.getElementById(\'blok\').style.display = "block";\n else document.getElementById(\'blok\').style.display = "none"; \n }\n function change_fac()\n { var type = $("#type_z").val(); if (type==0) return;\n var schet = $("#schet").val(); if (schet==0) return; \n var faculty = $("#faculty").val(); \n if (faculty>0) $.post(\'raspisanie_all_new.php\', {faculty : faculty, choice:1, type_z: type, schet: schet}, listLoad);\n }\n </script> \n </body> \n</html>' 

I should have got the table in html. class = "simple-little-table". But I do not get it in the request. What's wrong?

  • one
    If you don't get what you want, then what comes in return? Your request is being fulfilled, the answer arrives - that is, the POST request was successfully completed. If this application returns not what you expect, then it is no longer a query problem, but either a remote application or your data. - m9_psy
  • The fact of the matter is that if I make a post request through a specific tool, I get the html that is needed. But specifically through python. I only get the html, which I get by default through get - question1
  • Then try replacing the characters% 2F,% CF% EE% EA% E0% E7% E0% F2% FC with something readable (using urllib.parse). Encoding strings is required for GET requests and requests should automatically do this. Accordingly, for POST it is not necessary or it will be done by the library for you. Here are more details on this issue - stackoverflow.com/questions/6603928/… - m9_psy
  • Try using urllib.parse.unquote to create plain text from a URL. unquote("205.1617%2F2") for example. - Emin Mastizada

0