代碼試驗:
!pip install selenium
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from time import sleep
from datetime import datetime
import pandas as pd
errors = []
season = []
代碼運行良好,直到加載。當我撰寫以下代碼時會彈出一個錯誤:
for id in range(46605, 46985):
my_url = f'https://www.premierleague.com/match/{id}'
option = Options()
option.headless = True
driver = webdriver.Edge(options=option)
driver.get(my_url)
彈出以下錯誤:

錯誤截圖 2:

uj5u.com熱心網友回復:
使用基于Chromium的邊緣使用Selenium v4.x,您必須安裝以下軟體包:
msedge硒工具:
pip install msedge-selenium-tools代碼塊:
from msedge.selenium_tools import Edge s = Service('/path/to/edge') driver = Edge(service=s)
使用基于Chromium的邊緣 在里面 無頭模式你需要的EdgeOptions類。
代碼塊:
from msedge.selenium_tools import EdgeOptions from msedge.selenium_tools import Edge # make Edge headless edge_options = EdgeOptions() edge_options.use_chromium = True # required to make Edge headless s = Service('/path/to/edge') driver = Edge(service=s, options=edge_options)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/411711.html
標籤:
上一篇:如何使用ajax發布跨度ID
