2017-06-03 20 views
0

我試圖從URL「https://www.mtgstocks.com/lists/1」獲取數據。通過HTMLUnit我得到這個錯誤,我不知道從哪裏去。我甚至不明白錯誤的含義。HTMLUnit EcmaError類型錯誤

首先這是我的代碼:

import com.gargoylesoftware.htmlunit.BrowserVersion; 
import com.gargoylesoftware.htmlunit.WebClient; 
import com.gargoylesoftware.htmlunit.html.HtmlPage; 
import java.io.IOException; 

public class Main { 
public static void main(String[] args) throws Exception { 
    java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.OFF); 
    try { 

     WebClient webClient = new WebClient(BrowserVersion.CHROME); 
     HtmlPage page = webClient.getPage("https://www.mtgstocks.com/lists/1"); 
     webClient.getOptions().setJavaScriptEnabled(true); 
     //webClient.waitForBackgroundJavaScript(3000); 
    } catch (IOException ex) { 
     ex.printStackTrace(); 
     } 
    } 
} 

這是我的錯誤:

Exception in thread "main" ======= EXCEPTION START ======== 
EcmaError: lineNumber=[1] column=[0] lineSource=[<no source>] name=[TypeError] sourceName=[https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js] message=[TypeError: Expected argument of type object, but instead had type object (https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js#1)] 
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Expected argument of type object, but instead had type object (https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js#1) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:898) 
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) 
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:778) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:754) 
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:980) 
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:352) 
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:239) 
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:258) 
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:781) 
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) 
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:738) 
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1243) 
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1143) 
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:226) 
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:345) 
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3154) 
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2117) 
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:945) 
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:521) 
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:472) 
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) 
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:988) 
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:246) 
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:188) 
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:272) 
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160) 
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:520) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:394) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:459) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:444) 
at com.company.Main.main(Main.java:17) 
Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Expected argument of type object, but instead had type object (https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js#1) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3934) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.ensureScriptableObject(ScriptableObject.java:2194) 
at net.sourceforge.htmlunit.corejs.javascript.NativeObject.execIdCall(NativeObject.java:335) 
at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:94) 
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1540) 
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) 
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) 
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) 
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:292) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) 
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:769) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:883) 
... 32 more 
Enclosed exception: 
net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: Expected argument of type object, but instead had type object (https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js#1) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3915) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3899) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3924) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3934) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.ensureScriptableObject(ScriptableObject.java:2194) 
at net.sourceforge.htmlunit.corejs.javascript.NativeObject.execIdCall(NativeObject.java:335) 
at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:94) 
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1540) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:50) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script.r(https://www.mtgstocks.com:443/inline.c4ea8b629bf43d39fe04.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script.r(https://www.mtgstocks.com:443/inline.c4ea8b629bf43d39fe04.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script.r(https://www.mtgstocks.com:443/inline.c4ea8b629bf43d39fe04.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at script.r(https://www.mtgstocks.com:443/inline.c4ea8b629bf43d39fe04.bundle.js:1) 
at script(https://www.mtgstocks.com:443/inline.c4ea8b629bf43d39fe04.bundle.js:1) 
at script(https://www.mtgstocks.com:443/polyfills.eec762705290a3a04ae2.bundle.js:1) 
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:800) 
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) 
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:416) 
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:292) 
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3264) 
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:769) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:883) 
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:637) 
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:518) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:778) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:754) 
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:980) 
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:352) 
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:239) 
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:258) 
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:781) 
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) 
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:738) 
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1243) 
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1143) 
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:226) 
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:345) 
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3154) 
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2117) 
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:945) 
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:521) 
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:472) 
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) 
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:988) 
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:246) 
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:188) 
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:272) 
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:160) 
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:520) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:394) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:459) 
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:444) 
at com.company.Main.main(Main.java:17) 
======= EXCEPTION END ======== 

Process finished with exit code 1 

謝謝您的幫助!

回答

0

似乎是HtmlUnit中的一個錯誤。請打開一個問題。