liunx图形界面(ubuntu)下配置 selenium和chrome
2023-09-27 14:24:39 时间
cheome的下载地址(感谢网友整理归档,很方便)https://www.chromedownloads.net/chrome64linux-stable/
解压到ubuntu的桌面双击deb文件进行安装
然后下载对应版本driver
扔到/usr/selenium/路径中(先mkdir然后再cp过去)
然后在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");//无界面模式 }
启动程序,可以爬取了
相关文章
- 爬虫 Http请求,urllib2获取数据,第三方库requests获取数据,BeautifulSoup处理数据,使用Chrome浏览器开发者工具显示检查网页源代码,json模块的dumps,loads,dump,load方法介绍
- Chrome和Firefox的event显示
- Chrome Development Tool: [VM] file from javascript
- 为什么 Chrome 会说你的 SHA-2 证书链是“肯定不安全的”
- 这几个 Chrome 的 Tab 增强插件你都用上了吗?
- chrome视频无法播放的解决方法(Solve the problem of Google player cannot be played normally)
- Chrome Console 小技巧之 02 隐藏网络消息
- Chrome 开发工具之Network
- 20个Chrome DevTools调试技巧