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<WebElement> elements = wait

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

// 获取标签内容

String all = "";

for (WebElement element : elements) {

String tagContent = element.getText();

all += tagContent+",";

}

return all;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值