为什么会发生此错误-“ org.openqa.selenium.WebDriverException:已到达错误页面:about:neterror?e = dnsNotFound&xxx”,我该如何解决?

时间:2019-10-21 10:10:23

标签: java selenium firefox centos web-crawler

当我在Windows操作系统中运行代码时,就可以了。但是当我将其应用到centos服务器时,会发生以下错误,并且这种情况一直存在

我对此错误进行了一些研究,但在Chrome中找不到很少的信息。他们建议我应该在服务器中使用Chrome。但是我不认为这是解决方案。

然后我尝试查看是否对url部分进行了过度编码。但是url很好。

到目前为止,我对正在发生的事情以及如何解决此问题一无所知。

        // 设置浏览器使用的本地驱动
        String firefoxDriver = Global.getConfig("firefox.driver");
        System.setProperty("webdriver.gecko.driver",firefoxDriver); // 0.24.0 从配置文件中获取配置信息

        // 设置浏览器在本地的位置  如果是默认的安装位置,则不需要设置
        // 参考:System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
        String firefoxExe = Global.getConfig("firefox.execute");
        System.setProperty("webdriver.firefox.bin", firefoxExe);


        FirefoxOptions options = new FirefoxOptions();
        options.addArguments("disable-infobars");
        options.addArguments("--headless");
        options.setHeadless(true);

        // 创建驱动对象;
        FirefoxDriver driver = new FirefoxDriver(options);

        // 向指定网址发送请求
        driver.get(url);

我希望在发送请求之后,我可以获取pageSource,然后解析它以获取所需的信息。 但是当我在Centos7服务器上运行项目时,出现以下错误:

org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=dnsNotFound&u=http%3A//rd.huangpuqu.sh.cn/website/html/shprd/shprd_ztrd_cwh/List/list_0.htm&c=UTF-8&f=regular&d=%E6%88%91%E4%BB%AC%E6%97%A0%E6%B3%95%E8%BF%9E%E6%8E%A5%E8%87%B3%20rd.huangpuqu.sh.cn%20%E7%9A%84%E6%9C%8D%E5%8A%A1%E5%99%A8%E3%80%82
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: xxx
Driver info: xxx
Capabilities {xxx}

0 个答案:

没有答案