简体   繁体   English

web 使用 Selenium 和 Edge 使用 Python 刮擦时出现基本错误

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

Code trials:代码试验:

!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 = []

The code runs fine till loading.代码运行良好,直到加载。 An error pops in when I write the following code:当我编写以下代码时会弹出一个错误:

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)

The following error pops up:弹出以下错误:

错误截图 1

Error Screenshot 2:错误截图 2:

错误截图 2

To use the Chromium based with Selenium v4.x you have to install the following packages:要将基于ChromiumSelenium v4.x一起使用,您必须安装以下软件包:

  • msedge-selenium-tools : msedge硒工具

     pip install msedge-selenium-tools
  • Code Block:代码块:

     from msedge.selenium_tools import Edge s = Service('/path/to/edge') driver = Edge(service=s)

To use the Chromium based with in mode you need the EdgeOptions class.要在模式下使用基于Chromium,您需要EdgeOptions class。

  • Code Block:代码块:

     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