How to select element in drop-down list
Su-Da-Ko opened this issue · 0 comments
Su-Da-Ko commented
I want to select element in drop-down list, like "Select" method in Selenium, but only get result before select.
How I modify code below?
(Run in google colab)
from requests_html import AsyncHTMLSession
url = "https://hoge.com"
session = AsyncHTMLSession()
r = await session.get(url)
await r.html.arender(timeout=60, keep_page=True)
select = r.html.find("select")
if len(select) > 0:
print(select[0]) // <Element 'select' ... >
option = r.html.find("option")
print(option) // [<Element 'option' value='1' selected='selected'>, <Element 'option' value='1'>, <Element 'option' value='2'>, ... ]
f = await r.html.page.select('select', "3")
print(f) // ["3"]
option = r.html.find("option")
print(option) // [<Element 'option' value='1' selected='selected'>, <Element 'option' value='1'>, <Element 'option' value='2'>, ... ]