I've been grappling with using PhantomJS/Selenium/python-selenium to download a file to the filesystem.
I'm able to easily navigate through the DOM and click, hover etc. Downloading a file is, however, proving to be quite troublesome. I've tried a headless approach with Firefox and pyvirtualdisplay but that wasn't working well either and was unbelievably slow. I know That CasperJS allows for file downloads. Does anyone know how to integrate CasperJS with Python or how to utilize PhantomJS to download files. Much appreciated.
Python – Using Selenium with Python and PhantomJS to download file to filesystem
downloadphantomjspythonseleniumselenium-webdriver
Related Topic
- Java – Download a file with Android, and showing the progress in a ProgressDialog
- Python – How to delete a file or folder in Python
- Python – Get HTML source of WebElement in Selenium WebDriver using Python
- Wget command to download a file and save as a different filename
- Python – Download large file in python with requests
- Selenium – Headless browser testing with download functionality
Best Answer
Despite this question is quite old, downloading files through
PhantomJS
is still a problem. But we can use PhantomJS to get download link and fetch all needed cookies such as csrf tokens and so on. And then we can userequests
to download it actually:And now in
response.content
actual file content should appear. We can next write it withopen
or do whatever we want.