I'm having a problem solving the capcha on a site.
The system works like this, first I go to the site with the pupeter and fill in the necessary information, and I save the screenshot of that part with the pupeter to solve the captcha there.
Then I try to read it with the tesseract.js module, but the result I want does not appear here.
import puppeteer from "puppeteer";
import { createWorker } from "tesseract.js";
const worker = createWorker();
const start = async function () {
let launchOptions = { headless: false, args: ["--start-maximized"] };
const browser = await puppeteer.launch(launchOptions);
const page = await browser.newPage();
await page.setViewport({ width: 1366, height: 768 });
await page.setUserAgent(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
);
await page.goto(
"https://webihlaltakip.kgm.gov.tr/WebIhlalSorgulama/Sayfalar/Sorgulama"
);
await page.type('input[title="Plaka"]', "AA" as string);
const logo = (await page.$(
"#pnlUpdate > table > tbody > tr:nth-child(2) > td:nth-child(1) > table > tbody > tr:nth-child(2) > td"
)) as any;
await logo.screenshot({
path: "captchaImage.png",
});
setTimeout(() => {
(async () => {
await worker.load();
await worker.loadLanguage("eng");
await worker.initialize("eng");
const {
data: { text },
} = await worker.recognize("./captchaImage");
console.log(text);
await worker.terminate();
})();
}, 2000);
};
start();
For example, the code written in the captcha picture is 5000 then result is very different.