0

ON this page: https://razzball.com/mlbhittingstats/ , there is an option to get the CSV data of the page as a download. What I am wondering, is if there is a way to trigger this programatically..

I figure that button has to be pointing towards some url or some function and there is a way to call it. Otherwise I feel like I would have to use a webdriver and somehow click the button. Is this possible? Or do I have to use a headless, automated browser

J DOe
  • 453
  • 7
  • 12

1 Answers1

0

This "Export to CSV" feature is entirely javascript-based/client-side - the table is a implemented using the jQuery tablesorter library.

In order to do the "export" you would need a way to execute JavaScript in the context of the rendered page - arguably the easiest way to do it would be to use selenium to simply click the button, but you can also do trigger the "export to csv" programmatically which allow for options like Splash.

If you go "selenium route", make sure to allow CSV files to be downloaded automatically:


Another alternative idea would probably be to do the CSV exporting on your own - for instance, using pandas library and its read_html() to HTML parse the table and to_csv() to dump a DataFrame into CSV.

alecxe
  • 414,977
  • 106
  • 935
  • 1,083