【发布时间】:2020-07-01 00:41:58
【问题描述】:
我想将 javaFX 加载的网站转换为 JSOUP。 p
ublic class database {
public static ArrayList<String> database = new ArrayList<String>();
public static ArrayList<Integer> laenge = new ArrayList<Integer>();
public static ArrayList<Integer> tiefe = new ArrayList<Integer>();
public static void main(String[] args) throws IOException, JSONException {
// TODO Auto-generated method stub
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
String url = "http://www.google.com";
webEngine.load(url);
//get w3c document from webEngine
org.w3c.dom.Document w3cDocument = webEngine.getDocument();
// use jsoup helper methods to convert it to string
String htm = new org.jsoup.helper.W3CDom().asString(webEngine.getDocument());
// create jsoup document by parsing html
Document doc = Jsoup.parse(url, htm);
//Document doc = Jsoup.connect("http://ttp-schreiber.de/Mathematik/index2.html").get();
Element title = doc.body();
/*WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
webEngine.load("http://ttp-schreiber.de/Mathematik/index2.html");
*/
Elements html = doc.select("html");
Controller(html);
// System.out.println("+--+"+deeper(next(html,html.last()))[0][0]);
databasesafe();
}
我收到以下错误消息: 线程“主”java.lang.ExceptionInInitializerError 中的异常
怎么弄错了?
ETC 我这里有例子:
How to parse html from javafx webview and transfer this data to Jsoup Document?
在这行中 ist .get 错误:String html = new org.jsoup.helper.W3CDom().asString(webEngine.get);
【问题讨论】:
-
当您可以使用
JSoup直接解析 URL 时,为什么要这样做? -
JSOUP 不能使用javascript
-
我更新了答案。
标签: javafx