Package: selenium-profiles
Selenium-ProfilesOverwritedevice metricsusing SeleniumMobile and DesktopemulationUndetectedby Google, Cloudflare, creep-js usingselenium-driverlessModifying headerssupported usingSelenium-Interceptoror seleniumwireTouch Actionsdynamic proxies with authenticationmaking singlePOST, GET or other requests usingdriver.profiles.fetch(url)(syntax)headless unofficially supportedapply profile on already running driver withdriver.profiles.apply(profiles.Android())use ofseleniumwirefor the latest features, have a look at thedevbranchFeel free to test my code!Getting StartedDependenciesPython >= 3.7Chrome-BrowserinstalledInstallingInstallGoogle-Chrome(or another chromium-based browser)pip install selenium-profilesStart Driverfromselenium_profiles.webdriverimportChromefromselenium_profiles.profilesimportprofilesfromselenium.webdriver.common.byimportBy# locate elementsfromseleniumwireimportwebdriverprofile=profiles.Windows()# or .Androidoptions=webdriver.ChromeOptions()options.add_argument("--headless=new")driver=Chrome(profile,options=options,uc_driver=False)# get urldriver.get('https://abrahamjuliot.github.io/creepjs/')# test fingerprintinput("Press ENTER to exit: ")driver.quit()# Execute on the End!Don't forget to executedriver.quit()in the End. Else-wise your temporary folder will get flooded!Run with Google-ColabGoogle-Colab(file: master@google-colab/selenium_profiles.ipynb)ProfilesExample Profile:profile=\{"options":{"sandbox":True,"headless":False,"load_images":True,"incognito":True,"touch":True,"app":False,"gpu":False,"proxy":"http://example-proxy.com:9000",# note: auth not supported,"extension_paths":["path/to/extension_1",...],# directory, .crx or .zip"args":["--my-arg1",...],"capabilities":{"cap_1":"val_1","cap_2":"val_2"},"experimental_options":{"option1":"value1","option2":"value2"},"adb":False,# run on harware device over ADB"adb_package":"com.android.chrome","use_running_app":True},"cdp":{"touch":True,"darkmode":None,"maxtouchpoints":5,"cores":8,"cdp_args":[],"emulation":{"mobile":True,"width":384,"height":700,"deviceScaleFactor":10,"screenOrientation":{"type":"portrait-primary","angle":0}},"patch_version":True,# to patch automatically, or use "111.0.5563.111""useragent":{"platform":"Linux aarch64","acceptLanguage":"en-US","userAgent":"Mozilla/5.0 (Linux; Android 11; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Mobile Safari/537.36","userAgentMetadata":{"brands":[{"brand":"Google Chrome","version":"105"},{"brand":"Not)A;Brand","version":"8"},{"brand":"Chromium","version":"105"}],"fullVersionList":[{"brand":"Google Chrome","version":"105.0.5195.136"},{"brand":"Not)A;Brand","version":"8.0.0.0"},{"brand":"Chromium","version":"105.0.5195.136"}],"fullVersion":"105.0.5195.136","platform":"Android","platformVersion":"11.0.0","architecture":"","model":"HD1913","mobile":True,"bitness":"","wow64":False}}},"proxy":{"proxy":"socks5://user1:pass@example_jost.com:5001","bypass_list":["localhost"]}}selenium-driverlesswarning:this package is experimental and might include bugs, please report them atbug-reportsmight only work with 64-bit Python installationsprofiles might make it detectedrequirespip install selenium-driverless>=1.3.4firstfromselenium_profiles.webdriverimportChromefromselenium_profiles.profilesimportprofilesfromselenium_driverless.webdriverimportChromeOptionsfromselenium_driverless.types.byimportByprofile=profiles.Windows()# or .Androidoptions=ChromeOptions()# options.add_argument("--headless=new")driver=Chrome(profile,options=options,driverless_options=True)# get urldriver.get('https://nowsecure.nl#relax')# test fingerprintdriver.quit()# Execute on the End!seedocumentationfor usagesModify-headersusing selenium-wirefromselenium_profilesimportwebdriverfromselenium_profiles.profilesimportprofilesprofile=profiles.Android()driver=webdriver.Chrome(profile,uc_driver=False,seleniumwire_options=True)# or pass seleniumwire-optionsdefinterceptor(request):request.headers['New-Header']='Some Value'driver.request_interceptor=interceptor# checkout headersdriver.get("https://httpbin.org/headers")input("Press ENTER to quit..")driver.quit()exit()UsingSelenium-Injectorfromselenium_profiles.webdriverimportChromedriver=Chrome(injector_options=True)injector=driver.profiles.injector# modify headersinjector.declarativeNetRequest.update_headers({"test":"test_2","sec-ch-ua-platform":"Android"})rules=injector.declarativeNetRequest.dynamic_rulesheaders=injector.declarativeNetRequest._headersdriver.get("https://httpbin.org/headers")input("press ENTER to continue")# block imagesinjector.declarativeNetRequest.update_block_on(resource_types=["image"])driver.get("https://www.wikimedia.org/")input("press ENTER to exit")driver.quit()Touch_actionsExample demonstration scriptfromselenium_profiles.webdriverimportChromefromselenium_profiles.profilesimportprofilesfromselenium.webdriver.common.byimportByfromselenium.webdriverimportChromeOptionsfromselenium_profiles.scripts.driver_utilsimportTouchActionChain# Start Driveroptions=ChromeOptions()profile=profiles.Android()# or .Windows()driver=Chrome(profile,uc_driver=False,options=options)# initialise touch_actionschain=TouchActionChain(driver)driver.get("https://cps-check.com/de/multi-touch-test")touch_box=driver.find_element(By.XPATH,'//*[@id="box"]')# Get elementchain.touch_and_hold(touch_box)chain.pause(10)chain.release(touch_box)# perform actionschain.perform()# now you should see a touch indication# point on the Website for 10 seconds# quit driverinput('Press ENTER to quit Driver\n')driver.quit()connect to running driverUndetectability isn't garanteedfromseleniumimportwebdriverdriver=webdriver.Chrome()# driver allready started:)fromselenium_profiles.webdriverimportprofilesasprofile_managerfromselenium_profiles.profilesimportprofilesprofile=profiles.Android()# or .Android()driver.profiles=profile_manager(driver=driver,profile=profile)driver.profiles.apply(profile)driver.get('https://hmaker.github.io/selenium-detector/')# test fingerprintinput("Press ENTER to exit")driver.quit()# Execute on the End!Set proxies dynamically or with optionsfromselenium_profiles.webdriverimportChromefromselenium_profiles.profilesimportprofilesprofile=profiles.Windows()# or .Android()profile["proxy"]={"proxy":"http://user1:pass1@example_host.com:41149"}driver=Chrome(profile=profile,injector_options=True)driver.profiles.proxy.set_single("http://user2:pass2@example_host.com:41149")print(driver.profiles.proxy.proxy)driver.quit()# Execute on the End!To export a profile:go tohttps://js.do/kaliiiiiiiiiii/get_profilein your browser and copy the text.HelpPlease feel free to open an issue or fork!Known Bugsclick_as_touch makes automation hungTodojs-undetectability[navigator.connection]fonts don't match platformdoes not match worker scope (Emulation)crbug#1358491Navigator.userAgentNavigator.platformnavigator.hardwareConcurrencyemulation leak on new tabsdiskussionselenium-detectorEither Devtools Console is open or CDP Runtime Domain is enabled => patch javascript objects using a Proxy or disable CDP.Runtime domain?document.$cdc_asdjflasutopfhvcZLmcfl_document.$chrome_asyncScriptInfodriver.execute_script() usage (needs hook on called element)driver.execute_async_script() usage (needs hook on called element)driver.find_element() usagewindow.cdc_adoQpoasnfa76pfcZLmcfldefault metricsAndroidWindowsIOSLinuxTablettest.py scripttest_driver.pyassert useragent, profile_export (no error)Windowsuseragent-dataundetectedheadlessAndroiduseragent-dataundetectedheadlessDeprecatedStealth method(Detected by Google)buster captcha solver|wontfixAuthorsAurin AegerterLicenseShield:This work is licensed under aCreative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.DisclaimerI am not responsible what you use the code for!!! Also no warranty!AcknowledgmentsInspiration, code snippets, etc.Seleniumselenium-documentationREADME-Templateheadless_jsSelenium-StealthUndetected-ChromedriverSelenium-WireModheader-SeleniumModHeader docsbuster captcha solver|wontfixaudio_captcha_solverChromedriver-Options ListChrome DevTools Protocol (cdp_cmd)example_pypi_packagegoogle-colab installerscripts/touch_action_chaincdp_event_listenersproxy-authwebdriver-managerdynamic subclasses