Добрый день.
Очень прошу помочь в запуске chrome headless скраппера на vds (ubuntu 22.04).
Уже 3 дня ищу решение :(
Простой код (Python, Selenium)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://python.org")
print(driver.title)
driver.close()
После ssh подключения до запуска кода выполнил следующие команды:
sudo apt update
sudo apt upgrade
установил хром
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f
установил selenium и webdriver_manager
sudo apt install python3-pip
pip install selenium
pip install webdriver_manager
Запускаю код выше - ошибка.
Очень прошу помочь, совсем отчаялся.
Traceback (most recent call last):
File "/root/test.py", line 24, in <module>
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
File "/root/venv/lib/python3.10/site-packages/webdriver_manager/chrome.py", line 40, in install
driver_path = self._get_driver_binary_path(self.driver)
File "/root/venv/lib/python3.10/site-packages/webdriver_manager/core/manager.py", line 40, in _get_driver_binary_path
file = self._download_manager.download_file(driver.get_driver_download_url(os_type))
File "/root/venv/lib/python3.10/site-packages/webdriver_manager/core/download_manager.py", line 29, in download_file
response = self._http_client.get(url)
File "/root/venv/lib/python3.10/site-packages/webdriver_manager/core/http.py", line 36, in get
self.validate_response(resp)
File "/root/venv/lib/python3.10/site-packages/webdriver_manager/core/http.py", line 19, in validate_response
raise ValueError(
ValueError: response body:
Google-Edge-Cache: forbidden
Error: 7
request url:
https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip
response headers:
{'content-length': '37', 'content-type': 'text/plain', 'x-request-id': '6bf004ec-4d9e-4bd0-a5d6-a296a27fc6db', 'alt-svc': 'h3=":443"; ma=2592000, h3-29=":443"; ma=2592000', 'date': 'Mon, 21 Aug 2023 08:24:16 GMT', 'server': 'Google-Edge-Cache'}