From 29598e9c6c0ce4f00ae6fb826c92488e16451ecb Mon Sep 17 00:00:00 2001 From: Camille Rakotoarisoa Date: Wed, 22 Jun 2022 19:54:14 +0200 Subject: [PATCH] v1 --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 3 ++ README.md | 31 ++++++++++++++++ imagesUrl.txt | 0 index.js | 73 ++++++++++++++++++++++++++++++++++++++ original_images/.DS_Store | Bin 0 -> 6148 bytes package.json | 20 +++++++++++ 7 files changed, 127 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 README.md create mode 100644 imagesUrl.txt create mode 100644 index.js create mode 100644 original_images/.DS_Store create mode 100644 package.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1e2819e301c66884372a8884658fed55e0d0d0f2 GIT binary patch literal 6148 zcmeHK-EPw`6h7_>q+!#FgfwoDa>HGjx-mdpAcZn6c83&xE&z4OT6KXeu9B1vN>T24 z0eA{tgE!z=xPtH42DK^GxEX@UN3y?T`+RotIksaW5}i?Ri>OIN4iaPCMfMxxc1{ac zGd0W;s*gV9^q4YAXmcUjR#*kB0{@x7gUd1a2(fl*W4Gup&SQASd8*cm_6gt!>~AvjQ>c=g(P(s=8P1vNVzD05Qy8hlUyEV4&t9gqGde zxvZ%A0gTz%JAr*hwLRgjD+*ttAy&o#y)x_LIy9E5tiE^nX+`C46_r;jJuKnXcur?$ z2gOr1^94E=Pk9{My;Z;}@c${m`-6wX=o>6Gs;vW=x&i>}s8$A_e-xPG8T1X78qoq1 znhMlZVXhcL(^2o4INxBYQPWA7%ZD%{3v)veYIOAPsc;g$Mw?p&tOD~2tmtBs&;JL@ z@Bi~8Te1pR1W(#GIJa&hmYbbNXpRWu> { + // for each line in imagesUrl.txt, put the image url in array + const imagesUrl = await fs + .readFileSync("imagesUrl.txt", "utf8") + .split("\n") + .filter((url) => url !== ""); + + const browser = await puppeteer.launch({ headless: false }); + const page = await browser.newPage(); + await page.setViewport({ width: 1280, height: 800 }); + + for (let i = 0; i < imagesUrl.length; i++) { + const imagePath = await downloadOriginalImage(imagesUrl[i]); + + await page.goto("https://www.watermarkremover.io/upload", { + waitUntil: "load", + }); + + await page.waitForSelector("input[type=file]"); + const fileInput = await page.$("input[type=file]"); + await fileInput.uploadFile(imagePath); + + /* resolve captcha */ + await page.evaluate(() => { + window.scroll(0, 0); + }); + await sleep(1000); + await page.solveRecaptchas(); + /* end resolve captcha */ + + await page.waitForSelector(".hyUBYz"); + await page.click(".hyUBYz"); + + await sleep(500); + + // To clear all previous uploaded images from the page + await page.evaluate(() => { + localStorage.clear(); + }); + } +})(); + +const downloadOriginalImage = async (imageUrl) => { + const options = { + url: imageUrl, + dest: __dirname + "/original_images", + }; + + return download + .image(options) + .then(({ filename }) => { + return filename; + }) + .catch((err) => console.error(err)); +}; + +function sleep(ms) { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); +} diff --git a/original_images/.DS_Store b/original_images/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0