You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Selenium无法加载Fiverr联盟登录页面 求解决方案

解决Selenium加载Fiverr联盟登录页空白的问题

以下是针对你遇到的空白页面问题的具体解决方案:

1. 配置ChromeOptions规避反爬检测

网站可能通过识别Selenium的特征(如navigator.webdriver标记)阻止自动化访问,需修改浏览器配置模拟真实用户环境:

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

options = webdriver.ChromeOptions()
# 添加真实用户代理(可替换为你当前浏览器的UA)
options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36")
# 禁用自动化提示
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
# 禁用Blink运行时的自动化特性
options.add_argument("--disable-blink-features=AutomationControlled")

driver = webdriver.Chrome(options=options)
# 覆盖navigator.webdriver属性
driver.execute_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})")

2. 使用显式等待替代固定sleep

固定time.sleep()不可靠,显式等待可在元素出现时立即执行,避免无效等待:

url = "https://fiverraffiliates.com/loginaffiliate/"

try:
    driver.get(url)
    # 等待用户名输入框出现,最长等待20秒
    username_input = WebDriverWait(driver, 20).until(
        EC.presence_of_element_located((By.NAME, "user"))
    )
    print("Success")
    # 后续登录操作示例
    # username_input.send_keys("你的账号")
    # password_input = driver.find_element(By.NAME, "password")
    # password_input.send_keys("你的密码")
except TimeoutException:
    print("页面加载超时或元素未找到")
    driver.refresh()
finally:
    # 操作完成后可选择关闭浏览器
    # driver.quit()
    pass

3. 检查Chrome浏览器与驱动版本匹配

确保ChromeDriver版本和本地安装的Chrome浏览器版本完全一致,版本不匹配会导致页面加载异常。可从Chrome设置中查看浏览器版本,再下载对应版本的ChromeDriver。

4. 禁用浏览器扩展(可选)

部分扩展可能干扰页面加载,可添加参数禁用所有扩展:

options.add_argument("--disable-extensions")

内容的提问来源于stack exchange,提问作者thomas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 00:22:40