Skip to content
Advertisement

Scraping dynamic dropdown with Selenium in Python

I woud like a bit of help with the following. I am trying to scrape the elements of the tickers’ dropdown on this website: https://live.hxro.io/tixwix

My code is as follow using selenium

JavaScript

This will only return

JavaScript

As it is an Ajax call I am not sure how to retrieve the other tickers in an efficient way. I thought the function find_element’s’ will return all the elements into a list but I only get the first one tickers[1] is out of bound.

Screenshot of the page source: enter image description here

Thanks

Advertisement

Answer

The below code works fine on my local :

Explanation :

You need to click on accept cookies button and shall try with ExplicitWait plus you would need to click on a svg icon which is there in your drop down (XPATH : //span[text()='Last Price']/../following-sibling::*).

In the end span.moon contains all the elements that you are looking for.

Code :

JavaScript

output :

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement