centos 安装谷歌浏览器

centos安装谷歌浏览器_centos google浏览器_运维@小兵的博客-CSDN博客

https://googlechromelabs.github.io/chrome-for-testing/

谷歌driver下载地址

String url = "https://emweb.securities.eastmoney.com/pc_hsf10/pages/index.html?type=web&code="+code+"&color=b#/hxtc/tcld";

File f = new File("D:\\chromedriver-win64118\\");

if (f.exists()) {

System.setProperty("webdriver.chrome.driver", "D:\\chromedriver-win64118\\chromedriver.exe");

} else {

System.setProperty("webdriver.chrome.driver", "/opt/chromedriver-linux64/chromedriver");

}

// 指定Chrome浏览器核心

// 创建Chrome浏览器驱动

// 配置Chrome选项

ChromeOptions options = new ChromeOptions();

options.addArguments("--headless"); // 无界面运行

// 创建Chrome浏览器驱动

WebDriver driver = new ChromeDriver(options);

driver.get(url);

WebDriverWait wait = new WebDriverWait(driver, 3000);

// driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);

// 抓取网页内容

// String pageContent = driver.getPageSource();

List elements = wait

.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("boardName")));

// 获取标签内容

String all = "";

for (WebElement element : elements) {

String tagContent = element.getText();

all += tagContent+",";

}

return all;

你可能感兴趣的:(centos,linux,运维)