网页被硒污染,页面无法加载

2024-06-06 16:17:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经用Python创建了一个脚本来做一些网络垃圾处理,我的计算机上一切都运行顺利。几天前,我买了一台新电脑,当我运行脚本时,网站不会加载。我的意思是,谷歌浏览器打开了一个新窗口,但网站没有加载。我得到的只是一张空白页

我知道我在两台电脑上都有不同版本的Chrome(新的是v72和v80),所以我已经下载了与v80兼容的Chromedriver。如果我更改网站的名称,它将加载页面。另外,我还有一些运行得非常好的Web垃圾脚本

这是我的代码:

from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys
import os
from datetime import date, timedelta

from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By

import sys
sys._enablelegacywindowsfsencoding()

options = webdriver.ChromeOptions()

options.add_experimental_option("prefs", {
  "download.default_directory": r"\my_path\",
  "download.prompt_for_download": False,
  "download.directory_upgrade": True,
  "safebrowsing.enabled": True,
  "credentials_enable_service": False,
  "profile.password_manager_enabled": False
})

options.add_argument("--disable-notifications")
options.add_experimental_option('excludeSwitches', ['enable-automation']) 
options.add_argument("--disable-extensions")
options.add_argument("start-maximized")
options.add_argument("disable-infobars")


wdriver = webdriver.Chrome("my_path\\chromedriver80.exe", options=options)

#open
wdriver.get ("https://hub.checkout.com/login")

在最后一行之后,我得到的只是一个空白窗口,如下图所示。 enter image description here

你能帮我吗


Tags: fromimport脚本addfalse网站downloadselenium