How to scrape charts from a website with python?

前端 未结 2 1267
我寻月下人不归
我寻月下人不归 2021-01-07 15:10

EDIT:

So I have save the script codes below to a text file but using re to extract the data still doesn\'t return me anything. My code is:

2条回答
  •  旧巷少年郎
    2021-01-07 15:51

    Another way is to use Highcharts' JavaScript Library as one would in the console and pull that using Selenium.

    import time
    from selenium import webdriver
    
    website = ""
    
    driver = webdriver.Firefox()
    driver.get(website)
    time.sleep(5)
    
    temp = driver.execute_script('return window.Highcharts.charts[0]'
                                 '.series[0].options.data')
    data = [item[1] for item in temp]
    print(data)
    

    Depending on what chart and series you are trying to pull your case might be slightly different.

提交回复
热议问题