0

I am parsing an page through Beautifulsoup in Python. The page ( link : https://services.ecourts.gov.in/ecourtindia/cases/s_order.php?state=D&state_cd=1&dist_cd=37) has a select box.

I would like to get the selected text from the select box.

Here is the HTML text after selecting an option :

<select name="court_complex_code" id="court_complex_code" style="width: 250px;height:21px;" onchange="funCourtEstChange();">
<option value="0">Select Court Complex</option>
<option value="1@2">Mumbai City Sessions Court</option>
<option value="119@1">Mumbai, City Civil Court</option><option value="121@5">Sewree, City Civil Court</option>
<option value="133@3,4">Dindoshi, City Civil Court</option>
</select>

Notice the attribute, selected is not set to True. It uses Javascript to obtain the selected value using the following code :

var court_complex_code=document.getElementById('court_complex_code').value;

I would like to get the selected text ( & value) through Beautifulsoup. Any idea how to do it ?

Kiran
  • 8,034
  • 36
  • 110
  • 176
  • But you don't even know which one is seletected? – Sraw Jun 14 '18 at 07:16
  • That's correct. I am doing it in conjunction with Selenium. The user would select it manually. I would like to know which one is selected. Through `Javascript` it is possible as shown above. – Kiran Jun 14 '18 at 07:18
  • 1
    Will it be helpful? https://stackoverflow.com/a/30872875/5588279 – Sraw Jun 14 '18 at 07:30
  • Thanks a lot @Sraw, It really helped. Can you please convert this into an answer, so that It might help others as well – Kiran Jun 14 '18 at 07:34
  • As you can see, it is an existing answer, so what I really should do is to mark your question as duplicated... – Sraw Jun 14 '18 at 07:38

0 Answers0