There is such a form:

<div class="formulation clearfix"><h4 class="accesshide">Текст</h4><input type="hidden" name="q1437458:12_:sequencecheck" value="1"><div class="qtext">блабла</div><div class="ablock"><div class="prompt">текст:</div><div class="answer"><div class="r0"><input type="radio" name="q1437458:12_answer" value="0" id="q1437458:12_answer0"><label for="q1437458:12_answer0">a. один</label> </div> <div class="r1"><input type="radio" name="q1437458:12_answer" value="1" id="q1437458:12_answer1"><label for="q1437458:12_answer1">b. десять</label> </div> <div class="r0"><input type="radio" name="q1437458:12_answer" value="2" id="q1437458:12_answer2"><label for="q1437458:12_answer2">c. три</label> </div> <div class="r1"><input type="radio" name="q1437458:12_answer" value="3" id="q1437458:12_answer3"><label for="q1437458:12_answer3">d. 4</label> </div> <div class="r0"><input type="radio" name="q1437458:12_answer" value="4" id="q1437458:12_answer4"><label for="q1437458:12_answer4">e. 2</label> </div> </div></div><div class="im-controls"><input type="submit" id="q1437458:12_-submit" name="q1437458:12_-submit" value="Submit" class="submit btn"></div></div> 

How to simulate the choice of the first option and clicking on the "Submit" button using the requests library? Did this:

 payload = {'q1437458:4_answer': '0', 'q1437458:4_-submit': 'Submit'} r = s.post(ur, data=payload) 

but for some reason it does not work. I almost do not understand the web so please do not kick.

Each answer is assigned the status of incorrect/correct/notyetanswered . The server returns me <div id="q4" class="que multichoice immediatefeedback notyetanswered">

Form to check:

 <div id="q1" class="que multichoice immediatefeedback notyetanswered"> <div class="info"> <h3 class="no">Питання <span class="qno">1</span></h3> <div class="state">Не завершено</div> <div class="grade">Макс. оцінка до 1,00</div> <div class="questionflag editable" aria-atomic="true" aria-relevant="text" aria-live="assertive" id="yui_3_17_2_1_1464624154550_24"> <input type="hidden" name="q1439910:1_:flagged" value="0"> <input type="hidden" value="qaid=24910476&amp;qubaid=1439910&amp;qid=1285151&amp;slot=1&amp;checksum=30c911ce27cf7dd9ed3b562a4e53b861&amp;sesskey=6gFuOSeJFV&amp;newstate=" class="questionflagpostdata"> <input type="hidden" class="questionflagvalue" id="q1439910:1_:flaggedcheckbox" name="q1439910:1_:flagged" value="0"> <input type="image" class="questionflagimage" src="https://msn.khnu.km.ua/theme/image.php/clean/core/1464491009/i/unflagged" title="Відмітити це питання для майбутнього посилання" alt="Не помічено"><span class="questionflagtext" title="Відмітити це питання для майбутнього посилання">Відмітити питання</span> </div> </div> <div class="content" id="yui_3_17_2_1_1464624154550_641"> <div class="formulation clearfix" id="yui_3_17_2_1_1464624154550_640"> <h4 class="accesshide">Текст питання</h4> <input type="hidden" name="q1439910:1_:sequencecheck" value="1"> <div class="qtext">EventHandler середовища .NET Framework це</div> <div class="ablock" id="yui_3_17_2_1_1464624154550_639"> <div class="prompt">Виберіть одну відповідь:</div> <div class="answer" id="yui_3_17_2_1_1464624154550_638"> <div class="r0" id="yui_3_17_2_1_1464624154550_637"> <input type="radio" name="q1439910:1_answer" value="0" id="q1439910:1_answer0"> <label for="q1439910:1_answer0">a. Вбудована структура</label> </div> <div class="r1"> <input type="radio" name="q1439910:1_answer" value="1" id="q1439910:1_answer1"> <label for="q1439910:1_answer1">b. вбудований тип даних</label> </div> <div class="r0"> <input type="radio" name="q1439910:1_answer" value="2" id="q1439910:1_answer2"> <label for="q1439910:1_answer2">c. вбудований тип події</label> </div> <div class="r1"> <input type="radio" name="q1439910:1_answer" value="3" id="q1439910:1_answer3"> <label for="q1439910:1_answer3">d. вбудований тип делегата</label> </div> <div class="r0"> <input type="radio" name="q1439910:1_answer" value="4" id="q1439910:1_answer4"> <label for="q1439910:1_answer4">e. Інша відповідь</label> </div> </div> </div> <div class="im-controls"> <input type="submit" id="q1439910:1_-submit" name="q1439910:1_-submit" value="Відмітити" class="submit btn"> </div> </div> </div> </div> 

And the form after the check:

 <div id="q1" class="que multichoice immediatefeedback notyetanswered"> <div class="info"> <h3 class="no">Питання <span class="qno">1</span></h3> <div class="state">Не завершено</div> <div class="grade">Макс. оцінка до 1,00</div> <div class="questionflag editable" aria-atomic="true" aria-relevant="text" aria-live="assertive" id="yui_3_17_2_1_1464624154550_24"> <input type="hidden" name="q1439910:1_:flagged" value="0"> <input type="hidden" value="qaid=24910476&amp;qubaid=1439910&amp;qid=1285151&amp;slot=1&amp;checksum=30c911ce27cf7dd9ed3b562a4e53b861&amp;sesskey=6gFuOSeJFV&amp;newstate=" class="questionflagpostdata"> <input type="hidden" class="questionflagvalue" id="q1439910:1_:flaggedcheckbox" name="q1439910:1_:flagged" value="0"> <input type="image" class="questionflagimage" src="https://msn.khnu.km.ua/theme/image.php/clean/core/1464491009/i/unflagged" title="Відмітити це питання для майбутнього посилання" alt="Не помічено"><span class="questionflagtext" title="Відмітити це питання для майбутнього посилання">Відмітити питання</span> </div> </div> <div class="content" id="yui_3_17_2_1_1464624154550_641"> <div class="formulation clearfix" id="yui_3_17_2_1_1464624154550_640"> <h4 class="accesshide">Текст питання</h4> <input type="hidden" name="q1439910:1_:sequencecheck" value="1"> <div class="qtext">EventHandler середовища .NET Framework це</div> <div class="ablock" id="yui_3_17_2_1_1464624154550_639"> <div class="prompt">Виберіть одну відповідь:</div> <div class="answer" id="yui_3_17_2_1_1464624154550_638"> <div class="r0" id="yui_3_17_2_1_1464624154550_637"> <input type="radio" name="q1439910:1_answer" value="0" id="q1439910:1_answer0"> <label for="q1439910:1_answer0" id="yui_3_17_2_1_1464624154550_645">a. Вбудована структура</label> </div> <div class="r1"> <input type="radio" name="q1439910:1_answer" value="1" id="q1439910:1_answer1"> <label for="q1439910:1_answer1">b. вбудований тип даних</label> </div> <div class="r0"> <input type="radio" name="q1439910:1_answer" value="2" id="q1439910:1_answer2"> <label for="q1439910:1_answer2">c. вбудований тип події</label> </div> <div class="r1"> <input type="radio" name="q1439910:1_answer" value="3" id="q1439910:1_answer3"> <label for="q1439910:1_answer3">d. вбудований тип делегата</label> </div> <div class="r0"> <input type="radio" name="q1439910:1_answer" value="4" id="q1439910:1_answer4"> <label for="q1439910:1_answer4">e. Інша відповідь</label> </div> </div> </div> <div class="im-controls"> <input type="submit" id="q1439910:1_-submit" name="q1439910:1_-submit" value="Відмітити" class="submit btn"> </div> </div> </div> </div> 

  • What does it mean does not work? What response does the server return? - Donil
  • @Donil in the topic added. - zeronight
  • The first thing that catches your eye is that your input names are incorrect. For example, submit'a has the name q1437458:12_-submit , and not `q1437458: 4_-submit, the same applies to the selected value - Donil
  • @Donil in the request everything was correct, I just threw 4 questions here. Here, still, when all this business is monitored through dev. tools in chrome, after the check there are assigned some id, in the topic I threw the form before the check and after. - zeronight

0