cheome的下载地址(感谢网友整理归档,很方便)https://www.chromedownloads.net/chrome64linux-stable/

解压到ubuntu的桌面双击deb文件进行安装

liunx图形界面(ubuntu)下配置 selenium和chrome

然后下载对应版本driver

扔到/usr/selenium/路径中(先mkdir然后再cp过去)

liunx图形界面(ubuntu)下配置 selenium和chrome

 

 然后在java程序需要追加一些代码,判断系统类型,如果是linux的话,单独处理

  OSInfo.OSType ost = OSInfo.getOSType();

 

然后

if (ostypString.contains("LINUX")) {
            Map prefs = new HashMap();
            prefs.put("profile.default_content_settings.popups", 1); //设置为0禁止弹窗
            System.setProperty("webdriver.chrome.driver", "/usr/selenium/chromedriver");
            options.setExperimentalOption("prefs", prefs);
            options.addArguments("--headless");//无界面模式
        }

 启动程序,可以爬取了

liunx图形界面(ubuntu)下配置 selenium和chrome

 

相关文章:

  • 2022-01-14
  • 2022-12-23
  • 2021-11-19
  • 2021-07-21
  • 2021-06-23
  • 2021-12-11
  • 2022-01-30
猜你喜欢
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-01
  • 2022-02-16
  • 2022-02-21
  • 2021-04-22
相关资源
相似解决方案