How to download a file with Python, Selenium and PhantomJS

后端 未结 4 611
无人及你
无人及你 2021-01-06 12:31

Here is my situation: I have to login to a Website and download a CSV from there, headless from a linux server. The page uses JS and does not work without it.

After

4条回答
  •  余生分开走
    2021-01-06 13:20

    I recently used Selenium to utilize ChromeDriver to download a file from the web. This works because Chrome automatically downloads the file and stores it in the Downloads file for you. This was easier than using PhantomJS.

    I recommend looking into using ChromeDriver with Selenium and going that route: https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver

    EDIT - As pointed out below, I neglected to point to how to set up ChromeDriver to run in headless mode. Here's more info: http://www.chrisle.me/2013/08/running-headless-selenium-with-chrome/

    Or: https://gist.github.com/chuckbutler/8030755

提交回复
热议问题