Collection of patches for puppeteer and playwright to avoid automation detection and leaks. Helps to avoid Cloudflare and DataDome CAPTCHA pages. Easy to patch/unpatch, can be enabled/disabled on demand.
The rebrowser patches is great and i am sure there is a lot difference now from any puppeteer versions. What i found was like once we open a browser and type something it works perfect but trying to automate typing we are getting blocked. But clicks submits all works perfect only typing or pressing keyboard from rebrowser is identified. And one more thing is like I had mentioned issue earlier about iframe click that is still occurring in some cases. I am sharing my code here for reference with images. I have tried all different typing modules but no joy.
Audio to text
import requests
import speech_recognition as sr
import sys
import re
def convert_audio_to_text(audio_file):
recognizer = sr.Recognizer()
with sr.AudioFile(audio_file) as source:
recognizer.adjust_for_ambient_noise(source)
audio_data = recognizer.record(source)
try:
# Recognize the speech in the audio file
text = recognizer.recognize_google(audio_data, language="en-US")
open("feedback.html", "w").write(text)
text=text.split(' ')
main_text=[]
for x_e in text:
if x_e.lower() in number_mapping:
main_text.append(number_mapping[x_e.lower()])
else:
if x_e.isdigit():
main_text.append(x_e)
main_text=''.join(main_text)
return main_text
except sr.UnknownValueError:
print("Speech recognition could not understand audio")
except sr.RequestError as e:
print(f"Could not request results from Google Web Speech API; {e}")
The rebrowser patches is great and i am sure there is a lot difference now from any puppeteer versions. What i found was like once we open a browser and type something it works perfect but trying to automate typing we are getting blocked. But clicks submits all works perfect only typing or pressing keyboard from rebrowser is identified. And one more thing is like I had mentioned issue earlier about iframe click that is still occurring in some cases. I am sharing my code here for reference with images. I have tried all different typing modules but no joy.
Audio to text
import requests import speech_recognition as sr import sys import re
number_mapping = { "zero": "0", "one": "1", "won": "1",
"two": "2", "too": "2",
"to": "2",
"three": "3", "free": "3",
"four": "4", "for": "4",
"five": "5", "hive": "5",
"six": "6", "seven": "7", "heaven": "7",
"eight": "8", "ate": "8",
"nine": "9", "mine": "9", "sex":"6"
}
def download_audio(url): headers = { 'authority': 'dd.prod.captcha-delivery.com', 'accept': '/', 'accept-language': 'en-GB,en;q=0.9', 'cache-control': 'no-cache', 'dnt': '1', 'pragma': 'no-cache', 'range': 'bytes=0-', 'referer': 'https://geo.captcha-delivery.com/', 'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Brave";v="120"', 'sec-ch-ua-mobile': '?0', 'sec-ch-ua-platform': '"Linux"', 'sec-fetch-dest': 'audio', 'sec-fetch-mode': 'no-cors', 'sec-fetch-site': 'same-site', 'sec-gpc': '1', 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36', }
def convert_audio_to_text(audio_file): recognizer = sr.Recognizer() with sr.AudioFile(audio_file) as source:
recognizer.adjust_for_ambient_noise(source)
script,audio_url= sys.argv
audio_url='https://dd.prod.captcha-delivery.com/audio/2024-08-01/en/94295d999c064d3833bfb6e4ab825ad5.wav'
audio_file=download_audio(audio_url) numbers=convert_audio_to_text(audio_file)
numbers = re.sub(r'two|to', '2', numbers) numbers = re.sub(r'\D', '', numbers) print(numbers)
My rebrowser code
import { exec } from 'child_process'; import puppeteer from 'puppeteer'; import fs from 'fs/promises'; import { typeInto } from "@forad/puppeteer-humanize" import GoLogin from './gologin/src/gologin.js'; // import path from 'path'; // import { addExtra } from 'puppeteer-extra'; // import { delay } from './gologin/src/gologin-api.js'; // const puppeteer = addExtra(puppeteerCore);
const config = { mistakes: { chance: 10, delay: { min: 50, max: 500 } }, delays: { space: { chance: 20, min: 100, max: 200 } } }
try { const url = 'https://ticketing.liverpoolfc.com/en-GB/categories/home-tickets';
} catch (error) { console.log(
Error ${error.message}
) }async function switchToChallengeFrame(page) { const frames = page.frames(); let iframeFound = false; for (const frame of frames) { const frameElement = await frame.frameElement(); if (frameElement) { const tagName = await frameElement.getProperty('tagName').then(tag => tag.jsonValue()); if (tagName === 'IFRAME') { iframeFound = true; try { await frame.waitForSelector('#captcha-container', { timeout: 10000 }); console.log('Switched to iframe successfully'); return frame; } catch (error) { console.error('Could not access elements inside iframe:', error); return null; } } } }
}
async function getAudioText(audioUrl) { const command =
python audio_solve.py ${audioUrl}
;}
async function datadomCookie(page) { await new Promise(resolve => setTimeout(resolve, 4000)); const iframe = await switchToChallengeFrame(page);
}
package.json
{ "name": "datadome", "version": "1.0.0", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "description": "", "dependencies": { "@forad/puppeteer-humanize": "^1.1.6", "express": "^4.21.1", "puppeteer": "^23.6.0" } }