ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.71k stars 1.14k forks source link

Is it now detected / main code example is broken ? #1631

Open Kynastone opened 11 months ago

Kynastone commented 11 months ago
import undetected_chromedriver as uc
driver = uc.Chrome(headless=True,use_subprocess=False)
driver.get('https://nowsecure.nl')
driver.save_screenshot('nowsecure.png')

i tried this code and i get error

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 116, in spawn_main
    exitcode = _main
(fd, parent_sentinel)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 125, in _main
    prepare(preparation_data)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 236, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\mirko\Documents\Python Tests\test 1\first test.py", line 6, in <module>
    driver = uc.Chrome(options=options, use_subprocess=False)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\__init__.py", line 448, in __init__     
    self.browser_pid = start_detached(
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\site-packages\undetected_chromedriver\dprocess.py", line 35, in start_detached
    ).start()
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\process.py", line 121, in start
    self._popen = self._Popen(self)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\context.py", line 336, in _Popen
    return Popen(process_obj)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
    _check_not_importing_main()
  File "C:\Users\mirko\AppData\Local\Programs\Python\Python310\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main
    raise RuntimeError('''
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

then i run this code

import undetected_chromedriver as uc
import time

options = uc.ChromeOptions()
options.add_argument('--headless')
driver = uc.Chrome(options=options, use_subprocess=True)
driver.get('https://nowsecure.nl')
time.sleep(5)
driver.save_screenshot('C:/Users/mirko/Documents/Python Tests/test 1/nowsecure.png') # Wait for 5 seconds to ensure that the browser has fully loaded

driver.get('https://google.com')
time.sleep(5)
driver.save_screenshot('C:/Users/mirko/Documents/Python Tests/test 1/google.png') # Wait for 5 seconds to ensure that the browser has fully loaded

driver.get('https://facebook.com')
time.sleep(5)
driver.save_screenshot('C:/Users/mirko/Documents/Python Tests/test 1/facebook.png') # Wait for 5 seconds to ensure that the browser has fully loaded

driver.get('https://apple.com')
time.sleep(5)
driver.save_screenshot('C:/Users/mirko/Documents/Python Tests/test 1/apple.png') # Wait for 5 seconds to ensure that the browser has fully loaded

driver.get('https://amazon.com')
time.sleep(5)
driver.save_screenshot('C:/Users/mirko/Documents/Python Tests/test 1/amazon.png') # Wait for 5 seconds to ensure that the browser has fully loaded

driver.get('https://tronpick.io')
time.sleep(5)
driver.save_screenshot('C:/Users/mirko/Documents/Python Tests/test 1/tronpick.png') # Wait for 5 seconds to ensure that the browser has fully loaded

driver.quit()

print('finished!')

google nowsecure tronpick amazon apple facebook

seems it is blocked by nowsecure and tronpick.

if anyone want to try my code and confirm my output or not would be much apreciated. thanks!

teavver commented 11 months ago

in my case amazon responded with a captcha. other than that - same output. hope that helps amazon

Kynastone commented 11 months ago

in my case amazon responded with a captcha. other than that - same output. hope that helps amazon

well the captcha is totally fine i think.. the problem is cloudflare 😢

teavver commented 11 months ago

i'm pretty sure this is related: https://blog.cloudflare.com/turnstile-private-captcha-alternative/

Kynastone commented 11 months ago

i'm pretty sure this is related: https://blog.cloudflare.com/turnstile-private-captcha-alternative/

Yes and idk...it's been announced over an year ago

maxgamertyper commented 11 months ago

Yeah, even when automating the button press it either continuously reloads or just says failure

ghostbullet commented 11 months ago

Being detected anywhere with CF

teavver commented 11 months ago

in case someone still needs a fix for this - here's a simple undetectable setup using seleniumbase and uc inside the driver init configuration (passed all the websites in @Kynastone's initial comment):

from seleniumbase import Driver

driver = Driver(
        browser="chrome",
        uc=True,
        headless2=True,
        incognito=True,
        agent="user-agent of your choice",
        do_not_track=True,
        undetectable=True,
        )
LimitedTime19 commented 11 months ago

in case someone still needs a fix for this - here's a simple undetectable setup using seleniumbase and uc inside the driver init configuration (passed all the websites in @Kynastone's initial comment):

from seleniumbase import Driver

driver = Driver(
        browser="chrome",
        uc=True,
        headless2=True,
        incognito=True,
        agent="user-agent of your choice",
        do_not_track=True,
        undetectable=True,
        )

how do I use option arguments and also how do I load more than 2 extensions?

Kynastone commented 11 months ago

in case someone still needs a fix for this - here's a simple undetectable setup using seleniumbase and uc inside the driver init configuration (passed all the websites in @Kynastone's initial comment):

from seleniumbase import Driver

driver = Driver(
        browser="chrome",
        uc=True,
        headless2=True,
        incognito=True,
        agent="user-agent of your choice",
        do_not_track=True,
        undetectable=True,
        )

oh nice to know ! thanks for the reply i'll try it out in the next days

Shinoby92 commented 11 months ago

in case someone still needs a fix for this - here's a simple undetectable setup using seleniumbase and uc inside the driver init configuration (passed all the websites in @Kynastone's initial comment):

from seleniumbase import Driver

driver = Driver(
        browser="chrome",
        uc=True,
        headless2=True,
        incognito=True,
        agent="user-agent of your choice",
        do_not_track=True,
        undetectable=True,
        )

this workaround solved my problem. but why does it get triggered in the case not using sb

gerardsyd commented 7 months ago

This works, thank you! @teavver, any way to pass experimental options into seleniumbase? It appears there is a way to do so by creating a new SeleniumBase but it's unclear how to then call the driver. This is what i want to include to your code / driver

options.add_experimental_option("prefs", {
            "download.default_directory": DIRECTORY,
            "download.prompt_for_download": False,
            "download.directory_upgrade": True,
            "plugins.always_open_pdf_externally": True,
            "safebrowsing.enabled": True
})