Webdriver Update!
Автор: Michael Schrenk
Загружено: 2025-03-16
Просмотров: 115
Описание:
This video explains changes to Chromedriver and how to react.
For all of the reasons described in the video, i've decided to start using MSEdgeDriver inplace of ChromeDriver.
Here is the python code required to load EdgeDriver.
Some simple example demo code is also supplied below.
#------------------------------------------------------------------------
Libraries
import os
import sys
import selenium
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.edge.options import Options
#------------------------------------------------------------------------
Load Edge WebDriver (File must be executable)
edge_driver_path = os.path.join(os.getcwd(), 'msedgedriver.exe')
Check if the WebDriver file exists before proceeding
if not os.path.exists(edge_driver_path):
print(f"Error: Edge WebDriver not found at {edge_driver_path}")
sys.exit()
edge_service = Service(edge_driver_path) # Correct service instantiation
edge_options = Options()
edge_options.add_argument('user-agent=Super Secret Bot Project Vers 33.2')
Try loading the WebDriver
try:
driver = webdriver.Edge(service=edge_service, options=edge_options) # Corrected instantiation
print("WebDriver successfully loaded!")
except Exception as e: # Catch exceptions properly
print(f"WebDriver not loaded. Error: {e}")
sys.exit()
#-------------------------------------------------
Example: Open a test website to verify
driver.get("https://www.mepso.com")
print("Page Title:", driver.title)
Always close the driver when done
driver.quit()
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: