changed the way how patcher works (for those using multiple sessions/processes).
when not specifying a executable_path (the default, and recommended!), the filename gets randomized to <somehex>_chromedriver[.exe]. this should fix the issue for multiprocessing (although Chrome/driver itself has restrictions in this as well, see it using processhacker). As i told before, webdriver is a purely io-based operation which only sends and pulls data. multiprocessing/threading isn't going to help much. You'd better use asyncio.) added google-chrome-stable to the list, as some distro's have this name. Chrome(advanced_elements)bool, optional, default: False makes it easier to recognize elements like you know them from html/browser inspection, especially when working in an interactive environment default webelement repr: <selenium.webdriver.remote.webelement.WebElement (session="85ff0f671512fa535630e71ee951b1f2", element="6357cb55-92c3-4c0f-9416-b174f9c1b8c4")> advanced webelement repr <WebElement(<a class="mobile-show-inline-block mc-update-infos init-ok" href="#" id="main-cat-switcher-mobile">)> note: when retrieving large amounts of elements ( example: find_elements_by_tag("*") ) and **print** them, it does take a little more time for all the repr's to fetch **driver_executable_path=None** also known as executable_path if you really need to specify your own chromedriver binary. (don't log issues when you are not using the default. the downloading per session happens for a reason. remember this is a detection-focussed fork) **browser_executable_path=None** ( = browser binary path ) to specify your browser in case you use exotic locations instead of the more default install folders **advanced_elements=False** if set to True, webelements get a nicer REPR showing. this is very convenient when working interactively (like ipython for example). <WebElement(<a class="mobile-show-inline-block mc-update-infos init-ok" href="#" id="main-cat-switcher-mobile">)> instead of <selenium.webdriver.remote.webelement.WebElement (session="85ff0f671512fa535630e71ee951b1f2",element="6357cb55-92c3-4c0f-9416-b174f9c1b8c4")>
This commit is contained in:
commit
bf1cf1bc14
|
@ -0,0 +1,80 @@
|
|||
@echo off
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::
|
||||
:: QUICK TEST FOR UNDETECTED-CHROMEDRIVER TO CHECK IF CLOUDFLARE IAUAM CAN BE PASSED
|
||||
::
|
||||
:: To make it as clean as possible without interfering packages or plugins:
|
||||
:: - this creates a new python virtual environment
|
||||
:: - installs undetected chromedriver
|
||||
:: - executes a test
|
||||
:: - cleans up the virtual environment
|
||||
::
|
||||
:: this is for Windows only currently
|
||||
::
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
|
||||
set uc_test_dir=%temp%\ucvenv
|
||||
|
||||
set curdir=%CD%
|
||||
set prog=
|
||||
|
||||
|
||||
:: ===================
|
||||
:main
|
||||
|
||||
call :hasprog "conda"
|
||||
if [%prog%]==[conda] (
|
||||
echo "conda is found, activating..."
|
||||
call %prog% activate
|
||||
goto :next
|
||||
exit
|
||||
)
|
||||
|
||||
call :hasprog "python"
|
||||
if [%prog%]==[python] (
|
||||
echo "python is found"
|
||||
goto :next
|
||||
exit
|
||||
)
|
||||
|
||||
echo "no python interpreter or conda could be found. exiting"
|
||||
exit 1
|
||||
|
||||
|
||||
|
||||
:: ===================
|
||||
:hasprog
|
||||
call %~1 --help >nul 2>&1
|
||||
if ERRORLEVEL 0 (
|
||||
set prog=%~1
|
||||
)
|
||||
exit /B
|
||||
|
||||
|
||||
|
||||
:: ===================
|
||||
:next
|
||||
|
||||
mkdir %uc_test_dir%
|
||||
echo "created temp directory for the virtual environment: %uc_test_dir%"
|
||||
|
||||
python -m venv %uc_test_dir%
|
||||
|
||||
set pythonv=%uc_test_dir%\scripts\python
|
||||
%pythonv% -m pip install -U undetected-chromedriver
|
||||
%pythonv% -c "exec(\"import time,logging,undetected_chromedriver as uc,selenium.webdriver.support.expected_conditions as ec,selenium.webdriver.support.wait as wwait;logging.basicConfig(level=10);dr=uc.Chrome();dr.get('https://nowsecure.nl');wwait.WebDriverWait(dr,15).until(ec.visibility_of_element_located(('css selector','.hystericalbg')));print('====================WORKING=============');time.sleep(3)\")"
|
||||
|
||||
|
||||
if [%prog%]==[conda] (
|
||||
echo "deactivating conda env"
|
||||
%prog% deactivate
|
||||
)
|
||||
|
||||
cd %curdir%
|
||||
rd /S /Q %uc_test_dir%
|
||||
echo "cleaning up temp directory for the virtual environment: %uc_test_dir%"
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue