AutoControl Control your browser your way Forum               Install now from theChrome Web Store

ACtl.saveURL


Saves the content of a URL to a file or folder. There's no limit on the amont of data being downloaded other than available disk space. ACtl.saveURL(srcUrl,destPath) srcUrl Type: string Either a URL or data URI to get the data from. The data will be saved bit-for-bit identical to the source. destPath Type: string Local path or UNC path of the destination file or folder. If it ends with a slash or backslash, it will be interpreted as a folder, in which case the file name is deduced from srcUrl and the HTTP response headers.
It can be relative to the script's location (if there is one). It can also contain placeholders such as <desktop>, <documents> and others..
If the path doesn't exist, it'll be created.
Returns Type: Promise Resolves to: string Returns immediately. The Promise will resolve with the absolute file path to which srcUrl was saved. Throws Type: string Error description if srcUrl or destPath cannot be accessed.

Example

Save all images in a page to a folder in the desktop.

	//The destination folder name will be the page's domain
	let destFolder = `<desktop>/${location.hostname}/` ;
	let count = 0 ;
	//For each image in the page
	for( let image of document.images ){
		//If the image is bigger than 100x100 pixels
		if( image.src && image.width > 100 && image.height > 100 ){
			//Save it to the destination folder
			let filePath = await ACtl.saveURL(image.src, destFolder) ;
			console.log(++count, image.src, ' --> ', filePath) ;
		}
	}
	alert(count + ' IMAGES SAVED.') ;
	
Scripting API Script Isolation Asynchronicity Backgrnd Scripts GUI vs API ACtl.include ACtl.import ACtl.getFile ACtl.saveFile ACtl.saveURL ACtl.openURL ACtl.closeTab ACtl.runInTab ACtl.runInFrames ACtl.runInPageCtx ACtl.getTabInfo ACtl.getTabIds ACtl.TAB_ID ACtl.setTabState ACtl.captureTab ACtl.execAction ACtl.runCommand ACtl.getClipboard ACtl.setClipboard ACtl.expand ACtl.switchState ACtl.var ACtl.pubVar ACtl.on ACtl.off ACtl.sleep ACtl.STOP_CHAIN ACtl.STOP_FULL_SEQ