Summery of the question
The question is about how I can incorporate javascript modules in python.
I need to operate the fakebrowser's driver in python the same way it does in javascript so it can keep all the manipulated values of the browser fingerprint & system.
Full question
I have created an automated script for a website using selenium & python. What my code does is that it manages multiple accounts but after some time the website can detect that the accounts are being used from the same devices even after using various methods to make it undetectable (Proxies, User-Agent, Driver Options, and a ton more).
So the best module I found that can get my job done is fakebrowser because it can bypass most of the known ways websites use to detect automation. Fakebrowser can build a chromium driver but the problem I am facing is that it is using javascript and I don't want to rewrite all my code in javascript while I have already written it in Python (because I know only the basics in Javascript).
I have tried a lot of other solutions, below are only two of them but nothing I have tried so far have worked.
Attempt #1
I have tried using the chromium build which fakebrowser creates.
driver = webdriver.Chrome(executable_path=r"C:\Users\Hidden\.cache\puppeteer\chrome\win64-1069273\chrome-win\chrome.exe")
driver.get('https://pixelscan.com/')
It still leaks most of the information about my system & browser fingerprint because most of the modifications to the browser are done when you open the chrome build using fakebrowser's module.
Attempt #2
I have tried to open the driver using javascript and then start controlling it using selenium python which I found in here:
https://stackoverflow.com/questions/8344776/can-selenium-interact-with-an-existing-browser-session
Fakebrowser Javascript Code
const {FakeBrowser} = require('fakebrowser');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
!(async () => {
const createBrowserAndGoto = async (userDataDir, url) => {
const builder = new FakeBrowser.Builder()
.vanillaLaunchOptions({
headless: false,
args: ['--remote-debugging-port=9223']
})
.userDataDir(userDataDir);
const fakeBrowser = await builder.launch();
const page = await fakeBrowser.vanillaBrowser.newPage();
await page.goto(url);
await sleep(1000000000);
await fakeBrowser.shutdown();
};
createBrowserAndGoto('./fakeBrowserUserData1', 'http://pixelscan.net/').then(e => e);
})();
Selenium Python Code
from selenium import webdriver
from selenium.webdriver.chromium.options import ChromiumOptions
class Driver:
def __init__(self):
self.options = ChromiumOptions()
self.options.add_experimental_option("debuggerAddress", "127.0.0.1:9223")
def launch(self):
driver = webdriver.Chrome(r"C:\Users\User\.cache\puppeteer\chrome\win64-1069273\chrome-win\chrome.exe", chrome_options=self.options)
driver.get('http://pixelscan.net/')
Driver().launch()
Observation
Instead of connecting to the already open browser, it creates a new one but it's not using the same values as the fakebrowser driver does. So it's still leaking most of the information of my system & browser.
I need a way to control the same one that is already open or maybe I can use the driver variable created in JavaScript and pass it to the python code but I am not sure if that's even possible