Есть такая страница:
<html dir="ltr">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta name="viewport" content="width=device-width, minimum-scale=0.1, maximum-scale=5.0, user-scalable=yes"/>
<script src="../js/lib/knockout-2.3.0.js"></script>
<script src="../strings/stub/stub.js"></script>
<script src="../js/jssrc/base.js"></script>
<script src="../js/jssrc/model/wlmpor/index.model.htm"></script>
<script src="../js/jssrc/view_model/wlmpor/index.viewmodel.js"></script>
</head>
<frameset border="0" frameborder="no" framespacing="0">
<frame name="wlmframe" src="../startwlm/Start_Wlm.htm" />
</frameset>
</html>
в браузере все хорошо отрабатывает и можно получить остальной код страницы, но как мне запарсить на java core и вывести в консоль?
в просторах интернета нашел пример, но он ничем не помог((
public static void main(String[] args) throws IOException {
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
if (args.length > 0) {
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_60);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
HtmlPage page = webClient.getPage(args[0]);
System.out.println(page.asXml());
webClient.close();
}
}
выдает ошибку:
java -jar headlessbrowser.jar http://192.168.1.205
Exception in thread "main" com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for http://192.168.1.205/js/jssrc/view_model/startwlm/Start_Wlm.migration.js
at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:595)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1045)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:982)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:362)
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:236)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:257)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:792)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:748)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1175)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1115)
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:219)
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:303)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3146)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2074)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:922)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:438)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:389)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:991)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:246)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:190)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:269)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:534)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:400)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:317)
at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPageIfPossible(BaseFrameElement.java:188)
at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPage(BaseFrameElement.java:123)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames(HtmlPage.java:1916)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:251)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:541)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:400)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:317)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:469)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:450)
at Main.main(Main.java:22)
Нашел решение, все оказалось очень просто, достаточно использование HttpClient с нужным url.
public static void main(String[] args) throws IOException {
HttpClient client = new DefaultHttpClient();
HttpGet response = new HttpGet("http://192.168.1.205/js/jssrc/model/dvcinfo/dvccounter/DvcInfo_Counter_PrnCounter.model.htm");
ResponseHandler<String> handler = new BasicResponseHandler();
String body = client.execute(response, handler);
System.out.println(body);
}
Спасибо за внимание
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
например в переменную mail="gogglepost@gmailcom" и token="$23y$113$px/m3Gi54234dgdfd2m1
Я хочу написать функцию, которая будет сравнивать 3 элемента: если A = B = C, то выполнить какую-то функцию