【发布时间】:2012-12-14 15:45:12
【问题描述】:
如何使用 SWT Broser 将 html 页面代码转换为字符串?
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(100, 100);
Browser browser = new Browser(shell, SWT.NONE);
browser.setBounds(5, 75, 100, 100);
shell.open();
browser.setUrl("https://google.com");
String html = browser.getText(); //NOTHING!
while (!shell.isDisposed()) {
if (!display.readAndDispatch() && html == null) {
display.sleep();
}
}
display.dispose();
Syste.out.println(html); ////NOTHING!
那么,我该如何获取 html?最好的方法是,当 html-code 获取显示窗口后会关闭?
【问题讨论】: