Leave a Comment
            Javascript: скачать со странички картинки по маске
Массовая скачивалка картинок со страниц, где такая функция не предусмотрена.
Для кастомизации достаточно изменить внутренности функции getImgsData.
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57  | 
						function getImgsData() {     var imgs = [];     document.         querySelectorAll('span[role="rowheader"]').             forEach(function(item){                 var name = item.querySelector('a').innerHTML;                 imgs.push({src: "[some-prefix-here]/" + name, name: name});             });     return imgs; } function download(img) {     var link = document.createElement("a");     link.href = img.src;     link.download = img.name;     link.style.display = "none";     var evt = new MouseEvent("click", {         "view": window,         "bubbles": true,         "cancelable": true     });     document.body.appendChild(link);     link.dispatchEvent(evt);     document.body.removeChild(link);     console.log("Downloading..."); } /* Download all images in 'imgs'. Could be a function, returning the img array  * Optionaly filter them by extension (e.g. "jpg") and/or  * download the 'limit' first only  */ function downloadAll(imgs, ext, limit) {     if (typeof imgs === "function") {         imgs = imgs();     }     /* If specified, filter images by extension */     if (ext) {         ext = "." + ext;         imgs = [].slice.call(imgs).filter(function(img) {             var src = img.src;             return (src && (src.indexOf(ext, src.length - ext.length) !== -1));         });     }     /* Determine the number of images to download */     limit = (limit && (0 <= limit) && (limit <= imgs.length))         ? limit : imgs.length;     /* (Try to) download the images */     for (var i = 0; i < limit; i++) {         var img = imgs[i];         console.log("IMG: " + img.name + " (", img.src, ")");         download(img);     } } downloadAll(getImgsData, "", -1);  | 
					
За основу взят этот скрипт — http://stackoverflow.com/questions/19830088/download-multiple-images-at-once-with-javascript
Similar Posts
- None Found
 
LEAVE A COMMENT
Для отправки комментария вам необходимо авторизоваться.