downloadFile
boolean session.downloadFile ( String url, String fileName ) (professional and enterprise editions only)
boolean session.downloadFile ( String url, String fileName, int maxNumAttempts ) (professional and enterprise editions only)
boolean session.downloadFile ( String url, String fileName, int maxNumAttempts, boolean doLazy ) (enterprise edition only)
boolean session.downloadFile ( String url, String fileName, int maxNumAttempts ) (professional and enterprise editions only)
boolean session.downloadFile ( String url, String fileName, int maxNumAttempts, boolean doLazy ) (enterprise edition only)
Description
Downloads the file to the local file system.
Parameters
- url URL reference to the desired file, as a string.
- fileName Local file path when the file should be saved, as a string.
- maxNumAttempts (optional) Number of times the file will be requested without success, as an integer. Defaults to 3.
- doLazy (optional) Whether the file should be downloaded in a separate thread, as a boolean. Defaults to false.
Return Values
Returns true on successful download of the file otherwise it return false.
Change Log
Version | Description |
---|---|
4.5 | Available for professional and enterprise editions. Lazy scrape only available for enterprise edition. |
If the file to download requires that POST data is sent in order to get the file you would use saveFileOnRequest with a scrapeable file.
Using this method in a script takes the place of requesting the target URL as a scrapeable file.
Examples
Download File in a Separate Thread
// Downloads the image pointed to by the URL to the local C: drive.
// A maximum number of 5 attempts will be made to download the file,
// and the file will be downloaded in its own thread.
session.downloadFile( "http://www.foo.com/imgs/puppy_image.gif", "C:/images/puppy.gif", 5, true );
// A maximum number of 5 attempts will be made to download the file,
// and the file will be downloaded in its own thread.
session.downloadFile( "http://www.foo.com/imgs/puppy_image.gif", "C:/images/puppy.gif", 5, true );
scraper on 07/16/2010 at 4:54 pm
- Printer-friendly version
- Login or register to post comments