diprajpatra / selenium-stealth

Trying to make python selenium more stealthy.
MIT License
607 stars 88 forks source link

problem with stealth #29

Open LeaDer-E opened 2 years ago

LeaDer-E commented 2 years ago

i got a problem with the stealth, can i get any help pls? <3

from selenium import webdriver
from selenium_stealth import stealth
import time

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")

# options.add_argument("--headless")

options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r"/home/eslammustafa/Desktop/PY Projects")

stealth(driver,
        languages=["en-US", "en"],
        vendor="Google Inc.",
        platform="Win32",
        webgl_vendor="Intel Inc.",
        renderer="Intel Iris OpenGL Engine",
        fix_hairline=True,
        )

url = "https://bot.sannysoft.com/"
driver.get(url)
time.sleep(5)
driver.quit()

and the problem is:

Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license()" for more information.
>>> 
====== RESTART: /home/eslammustafa/Desktop/PY Projects/selenium-stealth.py =====

Warning (from warnings module):
  File "/home/eslammustafa/Desktop/PY Projects/selenium-stealth.py", line 12
    driver = webdriver.Chrome(options=options, executable_path=r"/home/eslammustafa/Desktop/PY Projects")
DeprecationWarning: executable_path has been deprecated, please pass in a Service object

Warning (from warnings module):
  File "/home/eslammustafa/.local/lib/python3.8/site-packages/requests/__init__.py", line 89
    warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
RequestsDependencyWarning: urllib3 (1.26.8) or chardet (3.0.4) doesn't match a supported version!
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 71, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/eslammustafa/Desktop/PY Projects'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode
    exec(code, self.locals)
  File "/home/eslammustafa/Desktop/PY Projects/selenium-stealth.py", line 12, in <module>
    driver = webdriver.Chrome(options=options, executable_path=r"/home/eslammustafa/Desktop/PY Projects")
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
    super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chromium/webdriver.py", line 90, in __init__
    self.service.start()
  File "/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py", line 86, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'PY Projects' executable may have wrong permissions. Please see https://chromedriver.chromium.org/home

>>> 
CaptainStabs commented 2 years ago

I don't think this has anything to do with stealth, try enabling write permissions (chmod a+x <path> iirc).

First error is telling you to provide the binary path as a service.

The way I use selenium is:

PATH = <path to chromedriver>
options = Options()
options.binary_location = <path to chrome binary>
self.driver = webdriver.Chrome(PATH, options=options)

the executable path requires an executable, not a folder.

You should change line 12 to:

driver = webdriver.Chrome("/home/eslammustafa/Desktop/PY Projects/chromedriver", options=options)

(I'm assuming executable_path is for the chromedriver, correct me if I'm wrong) Add whatever extension the chromedriver file has to the end.

LeaDer-E commented 2 years ago

Im really thank you 🥰🌹