Java 出现此错误的原因-“;org.openqa.selenium.webdrivexception:到达的错误页面:关于:neterror?e=dnsNotFound&;xxx“;,我该怎么修呢?

Java 出现此错误的原因-“;org.openqa.selenium.webdrivexception:到达的错误页面:关于:neterror?e=dnsNotFound&;xxx“;,我该怎么修呢?,java,selenium,firefox,centos,web-crawler,Java,Selenium,Firefox,Centos,Web Crawler,当我在windows操作系统中运行代码时,一切正常。但当我将其应用到centos server时,会出现以下错误,并且会不断发生 我对这个错误做了一些研究,但在Chrome中几乎找不到任何信息。他们建议我应该在服务器上使用Chrome,但我不认为这是一个解决方案 然后我试着看看我是否对url部分进行了过度编码,但是url很好 到目前为止,我还不知道发生了什么以及如何解决这个问题 // 设置浏览器使用的本地驱动 String firefoxDriver = Glob

当我在windows操作系统中运行代码时,一切正常。但当我将其应用到centos server时,会出现以下错误,并且会不断发生

我对这个错误做了一些研究,但在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);

我希望在发送请求后,我可以获取页面源代码,然后解析它以获得所需的内容。 但当我在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}

确实该URL有效吗?可以尝试使用nameserver 8.8.8.8(/etc/resolv.conf)或将主机放入主机文件(/etc/hosts)。肯定。当我在中使用该url时,我得到了正确的页面browser@pcalkinsYou确定URL有效吗?您可以尝试nameserver 8.8.8.8(/etc/resolv.conf)或将主机放入主机文件(/etc/hosts)。肯定。当我在中使用该url时,我得到了正确的页面browser@pcalkins