1

Sorry for cross-posting, here is my question:

I need to automate downloading multiple zip files from a web page. The page is inside a site that I need to log in to (HTTPS enabled).

The web page contains many direct links to zip files.

Of course, I managed to login successfully and reach the web page, I have also detected all the anchors (a) elements with the absolute URLs (hrefs).

I am performing a click() method call against an anchor element, looks like the download is started succesfully. Over 200MB of data is downloaded but it is not saved anywhere.

PhantomJS.exe process is growing in memory consumption, so it's clearly keeping the downloaded data into its private memory space, but it never drops the data on the disk (a normal behavior I suspect).

So, the question is, how can I save the downloaded data to the disk? Or even better, how can I instruct phantomjs to automatically detect a download and save the data on a predefined location on the disk?

I am using it in conjunction with Selenium WebDriver .NET.

Also posted here: https://groups.google.com/forum/#!topic/phantomjs/dJZPyJ0riPY

Edit based on Artjom B.'s comment:

I do create my webdriver object like this:

protected override RemoteWebDriver CreateRemoteWebDriver() {
    //return new FirefoxDriver();
    PhantomJSDriverService s = PhantomJSDriverService.CreateDefaultService();
    s.LocalStoragePath = @"g:\downloads\data";
    s.DiskCache = true;
    s.LogFile = @"g:\downloads\data\phantom.log";
    s.LoadImages = false;
    s.IgnoreSslErrors = true;

    return new PhantomJSDriver(s);
}

Unfortunately, no data other than the log file is created..

Adi
  • 5,113
  • 6
  • 46
  • 59
  • 1
    The downloaded data is probably in the cache folder under some cryptic name. If I remember correctly, there was an arbitrary download limitation of 30 seconds in PhantomJS. It would probably be easier to extract cookies and download links in order to download it directly without PhantomJS. – Artjom B. Sep 23 '15 at 12:35
  • @ArtjomB. pls check my edit – Adi Sep 23 '15 at 19:07
  • The `LocalStoragePath` is for ... wait for it ... [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage). It has nothing to do with a download path. Also, PhantomJS doesn't support automatic download from a click or something like that. – Artjom B. Sep 23 '15 at 19:08
  • @ArtjomB. how to change the cache folder? – Adi Sep 23 '15 at 19:09
  • any other method to automatically download? remember: 1. need to log in with user/pass; 2. https protocol is involved (if that matters after logging in) – Adi Sep 23 '15 at 19:13
  • 1
    The [cache folder](http://stackoverflow.com/a/27023965) cannot be changed (easily). The easiest would probably be finding the file links, extracting login cookies and send a WebRequest or something like that. Official PhantomJS doesn't support triggered file downloads, but there is – Artjom B. Sep 23 '15 at 19:19
  • I found this: http://www.codeproject.com/Tips/307548/Resume-Suppoert-Downloading as you say I only need to pass the cookie that was generated by phantomjs, right? – Adi Sep 23 '15 at 19:29

0 Answers0