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

Java Selenium登录受阻:网站新增Bot检测触发ERROR 15

问题:自动化Bot登录被网站拦截(ERROR 15)

我有一个运行近1年的自动化Bot,近期登录环节卡住。推测目标网站更新了Bot检测机制:用Bot打开新标签时会提示“Access denied ERROR 15. The request was blocked by our security service”,但常规浏览器访问一切正常。相关Login类代码如下,求解决方法:

public class Login {
    WebDriver driver;
    public Login() {
        System.setProperty("webdriver.chrome.driver", "C:\\Jars\\chromedriver.exe");        
        HashMap<String,Object> chromePrefs = new HashMap<String, Object>();
        chromePrefs.put("plugins.always_open_pdf_externally", true);
        chromePrefs.put("excludeSwitches", "enable-popup-blocking");    
        ChromeOptions options = new ChromeOptions();
    
        //--------------------------------------------------
            options.addArguments("--no-sandbox");
            options.addArguments("--disable-dev-shm-usage");
            options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
            options.setExperimentalOption("useAutomationExtension", null);             
            options.addArguments("window-size=1920,1080");
            options.addArguments("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36");
            options.addArguments("disable-infobars");
        driver = new ChromeDriver(options);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        
        //------------------------------------------------
        
        try {
            
            driver.get("https://www.fpl.com/my-account/account-landing.html#cards");
            Thread.sleep(3000);
            
            driver.findElement(By.id("emailOrUserId")).sendKeys("*******");
            driver.findElement(By.id("pwd")).sendKeys("********");
            driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
            driver.manage().window().maximize();
            driver.findElement(By.id("loginButton")).click();
            
        }catch(Exception ee) {ee.printStackTrace();}
    }
    public static void main(String args[]) {
        new Login();
    }
}
解决建议
  • 匹配Chrome与ChromeDriver版本:当前代码指定的Chrome版本是74,对应的驱动版本过于陈旧,很容易被网站检测到。立即升级Chrome浏览器到最新稳定版,同时下载对应版本的ChromeDriver,确保二者版本完全一致。
  • 强化浏览器指纹伪装:
    • 移除--no-sandbox参数,该参数是服务器环境的典型配置,会暴露自动化痕迹;
    • 替换固定的User-Agent,改用当前真实浏览器的UA(可在Chrome地址栏输入about:version查看),或者定期随机生成符合真实用户特征的UA;
    • 添加--disable-blink-features=AutomationControlled参数,这是隐藏window.navigator.webdriver属性的关键,能大幅降低被检测概率;
  • 模拟真实用户操作时序:
    • 替换硬编码的Thread.sleep(3000),改用WebDriverWait显式等待,根据页面元素加载状态动态等待,避免机械性停顿;
    • 在输入账号密码前,先点击输入框,停顿1-2秒再开始输入,输入过程中加入随机间隔(比如每个字符停顿100-300毫秒),模拟真实用户的输入节奏;
  • 加载真实用户配置文件:启动Chrome时加载本地日常使用的用户配置文件,通过options.addArguments("user-data-dir=C:\\Users\\你的用户名\\AppData\\Local\\Google\\Chrome\\User Data")实现,让浏览器携带真实的Cookie、缓存和插件信息;
  • 移除自动化特征参数:删除disable-infobars这类明确标记自动化的参数,同时将窗口最大化操作移到页面加载完成后,避免初始化阶段的异常操作;
  • 调整IP访问环境:如果Bot长期使用固定IP访问,可能已被网站标记为异常。尝试切换IP,或使用代理池模拟不同地区的用户访问行为。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 02:20:26