Created
February 17, 2023 11:19
-
-
Save novogrammer/c10a0ea2af505f2b1b0edcefcfa0a360 to your computer and use it in GitHub Desktop.
download100images.mjs
This file contains 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
import {execSync} from "child_process" | |
function zeroPadding(num, qty) { | |
return `${"0".repeat(qty)}${num}`.slice(qty * -1); | |
} | |
async function main(){ | |
for(let i=0;i<100;i+=1){ | |
const text=`image${zeroPadding(i,2)}`; | |
const filename=`${text}.jpg`; | |
const encodedText = encodeURIComponent(text); | |
const url = `https://dummyimage.com/600x400/000/fff.jpg?text=${encodedText}`; | |
const command=`curl "${url}" -o ${filename}`; | |
execSync(command); | |
} | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment