need to add speechtotext lib
This commit is contained in:
@@ -5,6 +5,7 @@ const PublishType = require("../models/PublishType");
|
||||
const {
|
||||
shell
|
||||
} = require('electron')
|
||||
const GeoCaptchaSolver = require("./GeoCaptchaSolver");
|
||||
// const RDV_URL = "http://192.168.0.44:8000/test_appointment.html"
|
||||
const RDV_URL = "https://rendezvousparis.hermes.com/client/register";
|
||||
BLANK_URL = "about:blank"
|
||||
@@ -114,8 +115,6 @@ class CommandorPage {
|
||||
async chooseCountry(page) {
|
||||
if (!page.isClosed()) {
|
||||
try {
|
||||
|
||||
|
||||
await page.locator(COUNTRY_ID).focus();
|
||||
await delay(getRandomWaitTime())
|
||||
await page.click(COUNTRY_ID);
|
||||
@@ -126,7 +125,6 @@ class CommandorPage {
|
||||
log(e);
|
||||
this.isTerminated = true;
|
||||
}
|
||||
// await page.click(COUNTRY_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +293,6 @@ class CommandorPage {
|
||||
try {
|
||||
let content = await currentPage.content();
|
||||
let captcha_url = "geo.captcha-delivery.com/captcha";
|
||||
|
||||
if (content.toString().includes(captcha_url)) {
|
||||
await this.checkAudioBtn();
|
||||
for (let i = 0; i < 15; i++) {
|
||||
@@ -327,7 +324,9 @@ class CommandorPage {
|
||||
let audioBtn = await this.page.frameLocator("iframe").locator("#captcha__audio__button");
|
||||
if (audioBtn) {
|
||||
log("audioBtn found")
|
||||
// audioBtn.click()
|
||||
audioBtn.click()
|
||||
let captchSolver = new GeoCaptchaSolver(this.page)
|
||||
captchSolver.solve()
|
||||
} else {
|
||||
log("audioBtn not found")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
const PLAY_AUDIO_BTN_ID = ".audio-captcha-play-button"
|
||||
const wget = require('node-wget');
|
||||
const crypto = require('crypto');
|
||||
const homedir = require('os').homedir();
|
||||
const dest_dir = homedir + "/wavs/"
|
||||
// iframe.query_selector('.audio-captcha-track').inner_html()
|
||||
const AUDIO_CAPTCHA_TRACK = ".audio-captcha-track";
|
||||
const CAPTCHA_CONTAINER = "#captcha-container";
|
||||
const WAV_URL_REGEX = "https:.+.wav";
|
||||
const re = new RegExp(WAV_URL_REGEX);
|
||||
|
||||
function delay(delayInMs) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve(2);
|
||||
}, delayInMs);
|
||||
});
|
||||
}
|
||||
|
||||
class GeoCaptchaSolver {
|
||||
constructor(page) {
|
||||
this.page = page
|
||||
}
|
||||
|
||||
|
||||
async solve() {
|
||||
console.log("solve() called.")
|
||||
console.log("play audio")
|
||||
let iframeHandler = await this.page.frameLocator("body > iframe");
|
||||
let playAudioBtn = await iframeHandler.locator(PLAY_AUDIO_BTN_ID);
|
||||
playAudioBtn.click();
|
||||
await delay(5000);
|
||||
// let captcha_track = await iframeHandler.locator(AUDIO_CAPTCHA_TRACK);
|
||||
// const handle = await this.page.frameLocator("iframe");
|
||||
// const contentFrame = await handle.contentFrame();
|
||||
// console.log(contentFrame)
|
||||
let captcha_container = await iframeHandler.locator(CAPTCHA_CONTAINER)
|
||||
// let result = await iframeHandler.evaluate(() => {
|
||||
// document.getElementsByClassName(AUDIO_CAPTCHA_TRACK)
|
||||
// })
|
||||
let html = await captcha_container.innerHTML()
|
||||
console.log("audio_tag: " + html);
|
||||
// find wav from html
|
||||
this.findWavFile(html)
|
||||
}
|
||||
|
||||
findWavFile(html) {
|
||||
let result = re.exec(html);
|
||||
if (result) {
|
||||
let audioUrl = result[0]
|
||||
let fileName = crypto.randomUUID() + ".wav"
|
||||
wget({url: audioUrl, dest: dest_dir + fileName}, function (error, response, body) {
|
||||
if (error) {
|
||||
console.log('--- error:');
|
||||
console.log(error); // error encountered
|
||||
} else {
|
||||
console.log('download the file successfully');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GeoCaptchaSolver
|
||||
Reference in New Issue
Block a user