0

ex url: (I'm sorry, but I think I need to remove the url due to personal reasons. you can use any other url containing highcharts.)

i want to get data(series) from highcharts with python3

Specifically, ex url-> highchart -> rightmost value (wednesday aug 04, 2021 serues 1:70.38)

i tried to get these values with selenium and many other stackoverflow's code. but i couldn't . pleeeeeeeease let me know

hyopark
  • 1
  • 1
  • 1
    Hi @hyopark, You can get the chart object by using this JS script: `$(document.getElementsByClassName('chart')[0]).highcharts()`. To get the last point data use: `$(document.getElementsByClassName('chart')[0]).highcharts().series[0].points[64]` – ppotaczek Aug 05 '21 at 08:51
  • Sorry, but I don't know selenium. I just run the above code in the browser console and it worked. Maybe you need to use some timeout before executing the script? – ppotaczek Aug 06 '21 at 09:00
  • 1
    oh, There is no need to say sorry! :) your commant was verrryyyyyy helpful! Anyway, you got the data with your code, so it's worth a try. I'll try everything~! If I solve this problem, I'll comment again. Thanks again ppotaczek! :) – hyopark Aug 06 '21 at 11:08
  • It's me again ppotaczek! I've just solved the problem!!I found out in StackOverflow why 'none' was returned. [https://stackoverflow.com/questions/5585343/getting-the-return-value-of-javascript-code-in-selenium] - "if variable is not defined, it returns None " So I changed the code you gave me to be more specific like"return parseFloat($(document.getElementsByClassName('chart')[0]).highcharts().series[0].points[64].series.yData[64])". Finally, It's working! I'm soooo happy!!! thank you so much ppotaczek!. – hyopark Aug 08 '21 at 12:19
  • 1
    #2 I'm sorry, but I think I need to remove the url due to personal reasons. I'll save the second comment for others. nice to meet you @ppotaczek. :) Thank you for your comment. I tried to your js code like ` from selenium import webdriver import time driver = webdriver.Chrome() url = "URL containing highcharts" driver.get(url) time.sleep(5) temp=driver.execute_script("$(document.getElementsByClassName('chart'[0]).highcharts().series[0].points[64];") print(temp) temp=driver.execute_script("$(document.getElementsByClassName('chart'[0]).highcharts()") print(temp)` but it return none. – hyopark Aug 08 '21 at 12:24

0 Answers0