From: Danial H. <dan...@ya...> - 2016-06-26 10:51:00
|
| Link to stack-exchange question in case its not displaying stuff properly in email: http://stackoverflow.com/questions/37986276/htmlunit-ws-connect-error-didnt-switch-protocols I am trying to use HtmlUnit to parse some data from http://www.plug.dj/baconetworks and for now I'm just trying to see if HtmlUnit can properly get the page I want, this is my code:final WebClient web = new WebClient(BrowserVersion.CHROME); web.getOptions().setCssEnabled(true); web.getOptions().setThrowExceptionOnScriptError(false); web.setAjaxController(new NicelyResynchronizingAjaxController()); web.getOptions().setUseInsecureSSL(true); final HtmlPage page = web.getPage("http://plug.dj/baconetworks"); web.waitForBackgroundJavaScript(60000); File file = File.createTempFile("HtmlUnit", ".html"); file.delete(); page.save(file); Runtime.getRuntime().exec("C:/Program Files/InternetExplorer/iexplore.exe " + file);However I get a lot of: WARNING: Obsolete content type encountered: 'text/javascript'.errors in console like 20 and I get this error:Jun 23, 2016 9:23:21 AM com.gargoylesoftware.htmlunit.javascript.host.WebSocket runSEVERE: WS connect errorjava.util.concurrent.ExecutionException: org.eclipse.jetty.websocket.api.UpgradeException: Didn't switch protocols at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:123) at com.gargoylesoftware.htmlunit.javascript.host.WebSocket$1.run(WebSocket.java:131) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Unknown Source)Caused by: org.eclipse.jetty.websocket.api.UpgradeException: Didn't switch protocolsat org.eclipse.jetty.websocket.client.io.UpgradeConnection.validateResponse(UpgradeConnection.java:314)at org.eclipse.jetty.websocket.client.io.UpgradeConnection.read(UpgradeConnection.java:241)at org.eclipse.jetty.websocket.client.io.UpgradeConnection.onFillable(UpgradeConnection.java:163)at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)... 3 more | |