こんにちはすべて私はhtmlを解析するためにjava-eeアプリでjsoupを使用しています
テキストを含む最初のタグを取得したいのですが、次のコードを実行しようとすると、例外が発生しました。
org.jsoup.select.Selector$SelectorParseException: Could not parse query :containsOwn(text)
at org.jsoup.select.Selector.findElements(Selector.java:143)
at org.jsoup.select.Selector.select(Selector.java:90)
at org.jsoup.select.Selector.select(Selector.java:68)
at org.jsoup.nodes.Element.select(Element.java:162)
コードは次のとおりです。
String html = "<html><head><style type=\"text/css\"></style></head><body><div style=\"font-family:times new roman,new york,times,serif;font-size:14pt\">first text<br><div><br></div><div style=\"font-family: times new roman,new york,times,serif; font-size: 14pt;\"><br><div style=\"font-family: times new roman,new york,times,serif; font-size: 12pt;\"><font size=\"2\" face=\"Tahoma\"><hr size=\"1\"><b><span style=\"font-weight: bold;\">one:</span></b> second text<br><b><span style=\"font-weight: bold;\">two:</span></b> third text<br><b><span style=\"font-weight: bold;\">three:</span></b> fourth text<br><b><span style=\"font-weight: bold;\">five:</span></b> fifth text<br></font><br>";
Document document = Jsoup.parse(html);
String firstText = document.select(":containsOwn(text)").first().text();
System.out.println(firstText);
だから何かアイデアはありますか?