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

使用Selenium访问eurobic.pt出现空白页,疑遭检测或拉黑求解决

解决Selenium访问eurobic.pt出现空白页的问题

看起来你遇到的是典型的网站反自动化检测问题,大概率是网站识别出了Selenium的特征,先别急着认定IP被拉黑,先试试下面这些针对性的解决方案:

1. 手动修改Firefox配置隐藏WebDriver标识

网站通常会通过检测浏览器的navigator.webdriver等JS属性来识别自动化工具,我们可以直接修改Firefox的参数来屏蔽这些特征:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

url = "https://www.eurobic.pt/"

# 配置Firefox选项
firefox_options = Options()
# 禁用WebDriver检测标识
firefox_options.set_preference("dom.webdriver.enabled", False)
firefox_options.set_preference("useAutomationExtension", False)
# 替换为你自己真实浏览器的User-Agent(可在Firefox地址栏输入about:config查看general.useragent.override)
firefox_options.set_preference(
    "general.useragent.override", 
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:117.0) Gecko/20100101 Firefox/117.0"
)

driver = webdriver.Firefox(options=firefox_options)
driver.get(url)

2. 使用专门的反检测Selenium库

如果手动配置太麻烦,推荐用undetected-chromedriver或者undetected-firefoxdriver,这些库已经封装好了全套绕过检测的逻辑,成功率更高:

先安装库(以undetected-chromedriver为例):

pip install undetected-chromedriver

然后编写代码:

from undetected_chromedriver import Chrome, ChromeOptions

url = "https://www.eurobic.pt/"

chrome_options = ChromeOptions()
chrome_options.add_argument("--start-maximized")  # 模拟正常窗口打开

driver = Chrome(options=chrome_options)
driver.get(url)

3. 排查IP是否被限制的情况

如果上面的方法都没用,再验证IP问题:

  • 用你的普通浏览器直接访问网站,如果也打不开,那就是IP被拉黑了。可以切换到手机热点、其他宽带网络,或者使用合规的静态代理IP(注意选高质量代理,避免再次触发反爬)。
  • 如果手动能正常访问,那肯定还是Selenium的检测没绕过去,回到上面的方法调整配置即可。

额外实用小技巧

  • 模拟人类操作节奏:在访问网站前加个随机停顿,比如import time; time.sleep(2),不要启动浏览器就立刻请求目标页面。
  • 不要使用默认窗口尺寸,设置成常规电脑屏幕大小,避免被识别为异常行为。

内容的提问来源于stack exchange,提问作者Sátiro

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 07:37:44