Closed ariya closed 4 years ago
I rebased @Vitallium s download-support on 2.0 here https://github.com/sgraham/phantomjs/tree/download-support-vs-2.0 in case anyone else wants it to save the bother of doing the merge/apply.
I followed the Linux build instructions here http://phantomjs.org/build.html and this simple example works OK. Would be great to have something in mainline!
var page = require('webpage').create();
page.onResourceReceived = function(status) {
console.log('onResourceReceived(' + status.contentType + ')');
if(status.stage === 'end') {
phantom.exit(0);
}
}
page.onResourceRequested = function(requestData, networkRequest) {
console.log('onResourceRequested(' + JSON.stringify(requestData) + ')');
}
page.onFileDownload = function(status) {
console.log('done');
return 'sample.pdf';
}
page.open('http://www.cbu.edu.zm/downloads/pdf-sample.pdf');
I compiled sgraham's branch above, but there seems to be a difference with the windows build by ankitgr8 (https://github.com/ankitgr8/phantomjs2.0). The build of sgraham's branch does not trigger onFileDownload in my case (zipfile download). So for the moment, I'm running ankitgr8's thing with wine. ( yes, I know -- newbie).
(masked) output of onResourceReceived:
Received { "body": "", "bodySize": 0, "contentType": "application/zip;charset=UTF-8", "headers": [ { "name": "Date", "value": "Thu, 14 Jan 2016 xx:xx:xx GMT" }, { "name": "Content-Disposition", "value": "attachment; filename=somefilename.zip" }, { "name": "Expires", "value": "0" }, { "name": "Cache-Control", "value": "must-revalidate, post-check=0, pre-check=0" }, { "name": "Pragma", "value": "public" }, { "name": "Keep-Alive", "value": "timeout=10, max=100" }, { "name": "Connection", "value": "Keep-Alive" }, { "name": "Transfer-Encoding", "value": "chunked" }, { "name": "Content-Type", "value": "application/zip;charset=UTF-8" } ], "id": XX, "redirectURL": null, "stage": "end", "status": 200, "statusText": "OK", "time": "2016-xx-xxTxx:xx:xx.xxxZ", "url": "https://domain/dir" }
Does downloading large files with PhantomJS 2.1 work?
How? How to download this quite big file from phamtomjs for example? https://download.jetbrains.com/idea/ideaIC-15.0.3.tar.gz
@lanzorg no, you can't download files with PhantomJS.
Did u tried my private build it is on windows https://github.com/ankitgr8/phantomjs2.0
I have also attached the sample code for the same
Any chance it will be available in the next release?
+1. File downloading would be a great feature for PhantomJS.
+1
+1
+1. Just wasted a couple of days converting my Selenium Firefox script that downloads a CSV to use PhantomJS only to find this ticket. Very sad now.
+1
+1
+1 очень нужна возможность скачивания файлов
+1
Thanking you Indranil Gayen
On Mon, Apr 4, 2016 at 8:52 PM, Staf4 notifications@github.com wrote:
+1 очень нужна возможность скачивания файлов
— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/ariya/phantomjs/issues/10052#issuecomment-205346505
+1
This is awesome. I am watching this issue for 2 years now and it amazes me how people keep bumping it :)
+1
+1
+Googolplex
5 years have passed!
It would be a really useful to implement download feature.
Yeah, why no download feature? ((( I want download files with phantomjs
I think the author is a liar and he never planned to release this feature.
I think the author is a liar and he never planned to release this feature.
Hey, the author is doing this on his spare time and is giving away all of it for free. Things gets in the way all the time and he haven't promised a deadline for this. Please try and show some respect...
Agree, but the issue has been opened 5 years ago! Does this feature require a lot of time to implement it? Because a lot of people really need it.
I would kindly ask all the haters to read about forking and pull requests.
Hey, don't blame the author please. They are doing it entirely for free. Only God does the same. It's very rude to tell this. If you want, develop it yourself.
Thanking you Indranil Gayen
On Sun, Jun 5, 2016 at 10:10 PM, Andrey Gadyukov notifications@github.com wrote:
I think the author is a liar and he never planned to release this feature.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ariya/phantomjs/issues/10052#issuecomment-223823148, or mute the thread https://github.com/notifications/unsubscribe/ACrtqe_LtWK0j6fhs7RIEdvz6wxeaK82ks5qIvwPgaJpZM4Ajhpl .
So many butt hurt in this thread :) )))))))))))))) .
hi, as i mentioned in my post (way back before already), in our case:
did help. i believe it depends on what you are trying to do but it may work for otheres too. not sure of the latest phantomjs status but we are downloading files through phantomjs all right... and it's helping us a lot!
Just a friendly reminder: PhantomJS team consists of volunteers. We do not always have the spare time necessary to implement every feature request. Competing priorities are unavoidable.
If you can't live with this, see #13861 where I outlined various ways you can help us. If you're still not satisfied, pay your favorite consultant to contribute a feature. These are all way more productive than whining or even insulting our work.
Please don't confuse those of us who have upvoted the feature request with the obnoxious comments above!
There is also the electron-based nightmare.js https://github.com/segmentio/nightmare which seems to perform a lot faster, too.
I rebased @Vitallium download-support on 2.1 https://github.com/SeNaP/phantomjs
Could you explain what does it mean? Can we already use download feature within phantomjs 2.1?
Yep
Clone repository https://github.com/SeNaP/phantomjs Build http://phantomjs.org/build.html
page.onResourceReceived = function(response) {
page.onFilePicker = function(){
console.log("save file:"+filename);
return "filename.extension"; // ex. file.zip
}
}
}
page.onDownloadFinished = function(status){
console.log('onDownloadFinished(' + status + ')');
}
page.onLoadFinished = function(status){
console.log('onLoadFinished(' + status + ')');
}
SeNaP, you can do binary for windows? I do not know how to compile phantomjs (tried - did not work)
@SeNaP So why is it still not merged in the official phantomjs repository? Please could you explain me?
@lanzorg my wild guess is that the feature is only implemented on 2.1 and would not compile on the current master branch. Update1: @Staf4 After a retarded amount of time I managed to compile SeNaP version, although for some odd reason its quite large than the original, it's working just fine: --> phantomjs.zip Update2: @SeNaP Would your fork work with selenium(python)?
I built the linux-64 version of @SeNaP 's fork in this link: phantomjs.tar.gz
I'm trying to figure out how to use it with poltergeist (https://github.com/teampoltergeist/poltergeist) so I can download files with Capybara (https://github.com/teamcapybara/capybara). Any help is welcome.
+1 😜
Did someone manage to build a Mac version of @SeNaP ’s fork?
+1 :100:
+1
I built the osx binary of @SeNaP 's fork. https://github.com/jomix/phantomjs/raw/2.1/bin/phantomjs SHA1 bbecc70411c8094e95b7b8c6f3a1403cc7edc1e3 Enjoy.
Has someone done it for Java-Selenium?
I have done it, but for which OS type Windows or Linux
On 08-May-2017 7:22 PM, "rakeshnambiar" notifications@github.com wrote:
Has someone done it for Java-Selenium?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ariya/phantomjs/issues/10052#issuecomment-299872691, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGCQKyCTLo46NSBdEl-msIviplbHbz8ks5r3x4xgaJpZM4Ajhpl .
Hello @ankitgr8 ... I am looking for Windows.
Thanks
Hi @ankitgr8 I am also looking for the same . Just would like to know how we can set the default download directory if we use your phantom js exe and download the file in java-selenium
Many Thanks Musaffir
Here's the link to download the exe if any one required. https://github.com/ankitgr8/phantomjs2.0.. The above exe has the download capability. IT run on windows 64 bit.
To set the default download.. U can create the download JS at runtime and set the download directory at that time.. below is the sample of the js code which can be create using JAVA .. CHECK for "downloadFileName"
BufferedWriter bos = new BufferedWriter(fos); bos.append("var page = require('webpage').create(); "); for(Cookie ck : webDriver.manage().getCookies()) { bos.append(" phantom.addCookie({ name: '"+ck.getName()+"', value: '"+ck.getValue()+"', domain: '"+ck.getDomain()+"' }); "); bos.newLine(); }
bos.append(" page.onFileDownload = function(status){console.log('onFileDownload(' + status + ')'); return '"+downloadFileName+"'; }"); bos.newLine(); bos.append(" page.onResourceReceived = function(status){console.log('onResourceReceived(' + status.stage + ')'); if(status.stage === 'end'){phantom.exit(1);}}"); bos.newLine(); bos.append(" page.onResourceRequested = function(status){console.log('onResourceRequested(' + status + ')'); }"); bos.newLine(); bos.append(" page.onFileDownloadError = function(status){console.log('onFileDownloadError(' + status + ')');phantom.exit(1);}"); bos.newLine(); bos.append(" page.onLoadStarted = function(status){console.log('onLoadStarted(' + status + ')');}"); bos.newLine(); bos.append(" page.onLoadFinished = function(status){console.log('onLoadFinished(' + status + ')');}"); bos.newLine(); bos.append(" page.open('"+downloadURL+"');"); bos.flush(); bos.close();
alexsa...@gmail.com commented:
Disclaimer: This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #52. :star2: 40 people had starred this issue at the time of migration.