Created
November 15, 2022 12:04
-
-
Save NavaneethVijay/02b11807757e441d6199a82e595e0232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function fetchImages(url, name){ | |
await fetch(url).then( async(res) => { | |
const blob = await res.blob(); | |
const newBlob = new Blob([blob]); | |
const blobUrl = window.URL.createObjectURL(newBlob); | |
const link = document.createElement('a'); | |
link.href = blobUrl; | |
link.setAttribute('download', name); | |
document.body.appendChild(link); | |
link.click(); | |
link.parentNode.removeChild(link); | |
// clean up Url | |
window.URL.revokeObjectURL(blobUrl); | |
}) | |
} | |
let categories = jQuery(".sub-category").slice(140, 147); | |
Array.prototype.forEach.call(categories, async (cat) => { | |
let srcimage = jQuery(cat).find('img').attr('src'); | |
let brandText = jQuery(cat).find('h4 strong').text(); | |
let renamed = brandText.replace(/\s/g, '-'); | |
await fetchImages(srcimage, renamed+".jpg") | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment