Reputation: 441
I am trying to scrape from the following website: https://www.legifrance.gouv.fr/rechJuriJudi.do?reprise=true&page=1
I am only interested in a specific subset of the results it can present so I want to use Selenium to fill in a search query.
To be more specific there are 2 parts I am interest in:
<select name="champJuridictions" id="champ1" class="textarea"><option value="" class="optionPaire">-- Toutes les juridictions --</option>
<option value="cour de cassation" selected="selected" class="optionImpaire">Cour de cassation</option>
<option value="juridiction d'appel" class="optionPaire">Juridictions d'appel</option>
<option value="juridictions du premier degre" class="optionImpaire">Juridictions du premier degré</option>
<option value="tribunal des conflits" class="optionPaire">Tribunal des conflits</option></select>
Which is a dropdown window, where I want to pick one of the options (the first one).
The other is an open field which I have to fill with a word.
<span class="inputCode">
<input type="text" name="champMotsRecherches1" value="" id="champ7" class="textarea">
</span>
Where value should be equal to "Impôt".
How would I fill such a query ?
Upvotes: 0
Views: 200
Reputation: 1008
For a text box, you can use the Selenium find_element_by_id
method and then use the send_keys
method on that element to send whatever input you wish.
browser.find_element_by_id("my_id").send_keys("my_text")
For a dropdown menu, you can use either select_by_index
or select_by_visible_text
.
menu = browser.find_element_by_id("my_dropdown_menu")
menu.select_by_index(index)
menu.select_by_visible_text("text")
Additional Resources:
http://selenium-python.readthedocs.io/locating-elements.html
http://thiagomarzagao.com/2013/11/12/webscraping-with-selenium-part-1/
Upvotes: 1