簡體   English   中英

web 使用 Selenium 和 Edge 使用 Python 刮擦時出現基本錯誤

[英]Basic Error while web scraping using Selenium and Edge with Python

代碼試驗:

!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)

彈出以下錯誤:

錯誤截圖 1

錯誤截圖 2:

錯誤截圖 2

要將基於ChromiumSelenium 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 class。

  • 代碼塊:

     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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM