public String getGN(String code) {
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\”);
System.setProperty(“webdriver.chrome.driver“, “D:\chromedriver–win64118\chromedriver.exe“);
} else {
System.setProperty(“webdriver.chrome.driver“, “/opt/chromedriver–linux64/chromedriver“);
}
ChromeOptions options = new ChromeOptions();
options.addArguments(“–headless“); // 无界面运行
options.addArguments(“–no–sandbox“);
options.addArguments(“–disable-gpu“);
options.addArguments(“–disable-dev–shm-usage”);
WebDriver driver = new ChromeDriver(options);
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”)));
for (WebElement element : elements) {
String tagContent = element.getText();
}
return all;
}
原文地址:https://blog.csdn.net/zhuixunhebe1/article/details/134732066
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_27304.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!