webClient模拟登录网站报错

十月 06, 2016 8:42:18 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:18 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:18 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:18 下午 com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController processSynchron
信息: Re-synchronized call to http://172.16.51.37/notice_listJSON.html
十月 06, 2016 8:42:18 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify
警告: Obsolete content type encountered: 'text/javascript'.
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter error
严重: error: message=[missing { before function body] sourceName=[script in http://172.16.51.37/home_welcome.html from (85, 36) to (106, 10)] line=[87] lineSource=[ function initArray()...{ ] lineOffset=[26]
十月 06, 2016 8:42:19 下午 com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine handleJavaScriptException
信息: Caught script exception
======= EXCEPTION START ========
Exception class=[net.sourceforge.htmlunit.corejs.javascript.EvaluatorException]
com.gargoylesoftware.htmlunit.ScriptException: missing { before function body (script in http://172.16.51.37/home_welcome.html from (85, 36) to (106, 10)#87)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:921)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:746)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:711)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:763)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:904)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:307)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:368)
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:238)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:257)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:772)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:729)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1209)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1111)
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:207)
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:337)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3137)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2100)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:927)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:506)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:459)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:979)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:241)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:187)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:269)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:157)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:512)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:386)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:304)
at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPageIfPossible(BaseFrameElement.java:184)
at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPage(BaseFrameElement.java:122)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames(HtmlPage.java:1818)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:226)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:519)
at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2147)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:946)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions(JavaScriptEngine.java:1033)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:806)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:749)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:696)
at TestC.main(TestC.java:45)

2个回答

Caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: missing { before function body (script in http://172.16.51.37/home_welcome.html from (85, 36) to (106, 10)#87)
at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.error(StrictErrorReporter.java:65)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:188)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:167)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:255)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:244)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:237)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parseFunctionBody(Parser.java:627)
at net.sourceforge.htmlunit.corejs.javascript.Parser.function(Parser.java:829)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:548)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:492)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileImpl(Context.java:2660)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1623)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:172)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1615)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:737)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:906)
... 43 more
Enclosed exception:
net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: missing { before function body (script in http://172.16.51.37/home_welcome.html from (85, 36) to (106, 10)#87)
at com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter.error(StrictErrorReporter.java:65)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:188)
at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:167)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:255)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:244)
at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:237)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parseFunctionBody(Parser.java:627)
at net.sourceforge.htmlunit.corejs.javascript.Parser.function(Parser.java:829)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:548)
at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:492)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileImpl(Context.java:2660)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1623)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory$TimeoutContext.compileString(HtmlUnitContextFactory.java:172)
at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1615)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:737)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:906)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:628)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:515)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:746)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.compile(JavaScriptEngine.java:711)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:763)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:904)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:307)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:368)
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:238)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:257)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:772)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:729)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1209)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1111)
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:207)
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:337)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3137)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2100)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:927)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:506)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:459)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:979)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:241)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:187)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:269)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:157)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:512)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:386)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:304)
at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPageIfPossible(BaseFrameElement.java:184)
at com.gargoylesoftware.htmlunit.html.BaseFrameElement.loadInnerPage(BaseFrameElement.java:122)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadFrames(HtmlPage.java:1818)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:226)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:519)
at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2147)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:946)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.processPostponedActions(JavaScriptEngine.java:1033)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:806)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:749)
at com.gargoylesoftware.htmlunit.html.DomElement.click(DomElement.java:696)
at TestC.main(TestC.java:45)
== CALLING JAVASCRIPT ==

today=new Date(); 
function initArray()...{ 
this.length=initArray.arguments.length 
for(var i=0;i<this.length;i++) 
this[i+1]=initArray.arguments[i] } 
var d=new initArray( 
"星期日", 
"星期一", 
"星期二", 
"星期三", 
"星期四", 
"星期五", 
"星期六"); 
document.write( 
"<font style='font-size:9pt;font-family: 宋体''> ", 
today.getYear(),"年", 
today.getMonth()+1,"月", 
today.getDate(),"日", 
d[today.getDay()+1], 
"</font>" );  

======= EXCEPTION END ========

有玩过这个的吗?求解答。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
java 爬虫 新浪微博 webclient 模拟登陆 “登陆”按钮无效
用WebClient模拟新浪微博登陆,有js加载问题: 异常如下: 2016-03-10 18:06:19,311 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,025 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,059 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,204 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [v="0", version:0, domain:.taobao.com, path:/, expiry:null] Illegal domain attribute "taobao.com". Domain of origin: "js1.t.sinajs.cn" 2016-03-10 18:06:21,204 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [cookie2="1cb93763dd883cf48427d2013efbb15b", version:0, domain:.taobao.com, path:/, expiry:null] Illegal domain attribute "taobao.com". Domain of origin: "js1.t.sinajs.cn" 2016-03-10 18:06:21,204 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [t="e5f50b797c4e59839d80b1961ae45398", version:0, domain:.taobao.com, path:/, expiry:Wed Jun 08 18:06:21 CST 2016] Illegal domain attribute "taobao.com". Domain of origin: "js1.t.sinajs.cn" 2016-03-10 18:06:21,205 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [_tb_token_="6v92BCkEPJskjf", version:0, domain:.taobao.com, path:/, expiry:null] Illegal domain attribute "taobao.com". Domain of origin: "js1.t.sinajs.cn" 2016-03-10 18:06:21,249 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,331 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,340 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,358 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,395 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,412 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,451 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,533 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,728 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:21,809 [main] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'text/javascript'. 2016-03-10 18:06:22,071 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:22,084 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:22,143 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [cna="HjVoD15v7R4CAdz4Edobp0iZ", version:0, domain:.mmstat.com, path:/, expiry:Sun Mar 08 18:06:22 CST 2026] Illegal domain attribute "mmstat.com". Domain of origin: "g.alicdn.com" 2016-03-10 18:06:22,143 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [sca="37e55bc2", version:0, domain:.mmstat.com, path:/, expiry:null] Illegal domain attribute "mmstat.com". Domain of origin: "g.alicdn.com" 2016-03-10 18:06:22,143 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [tbsa="a63b6f131cd4ff69ca5bf61d_1457604382_1", version:0, domain:.mmstat.com, path:/, expiry:null] Illegal domain attribute "mmstat.com". Domain of origin: "g.alicdn.com" 2016-03-10 18:06:22,143 [main] WARN [org.apache.http.client.protocol.ResponseProcessCookies] - Cookie rejected [atpsida="13075126e2ff6c8b00f358f8_1457604382", version:0, domain:.mmstat.com, path:/, expiry:Sun Mar 08 18:06:22 CST 2026] Illegal domain attribute "mmstat.com". Domain of origin: "g.alicdn.com" 2016-03-10 18:06:23,071 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:23,081 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:51,208 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:51,226 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:51,302 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://wbpctips.mobile.sina.cn/adfront/loginadv.php?posid=pos55dc4af3e7219&psid=PDPS000000025446&cip=220.248.17.218&cursor=15&eData=32.07,1&uid=1000959614999&callback=wbad_14576528474261&rnd=14577027909572', but got 'text/html'. 2016-03-10 18:06:51,313 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:51,343 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:06:51,435 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Expected content type of 'application/javascript' or 'application/ecmascript' for remotely loaded JavaScript element at 'http://login.sina.com.cn/sso/prelogin.php?entry=weibo&callback=sinaSSOController.preloginCallBack&su=&rsakt=mod&client=ssologin.js(v1.4.18)&_=1457604411336', but got 'text/html'. 2016-03-10 18:07:21,391 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:07:21,422 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] WARN [com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl] - Obsolete content type encountered: 'application/x-javascript'. 2016-03-10 18:07:51,352 [JS executor for com.gargoylesoftware.htmlunit.WebClient@145a27f] INFO [com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine] - Caught script exception 模拟点击“登陆”的a标签,预计因为js没有加载所以无法提交;a标签点击过后 还是返回的登陆界面! 模拟点击代码: HtmlAnchor login_a = page.getFirstByXPath("//*[@id=\"pl_login_form\"]/div[2]/div[1]/div/a[2]"); login_a.click(); 有谁知道什么解决不?
winform使用webclient上传文件报错,是怎么回事???具体如下
![图片说明](https://img-ask.csdn.net/upload/201505/09/1431155130_954732.png) 到底是怎么回事??附上服务端代码 protected void Page_Load(object sender, EventArgs e) { // 在此处放置用户代码以初始化页面 foreach (string f in Request.Files.AllKeys) { string hx=Request.QueryString ["picname"]; HttpPostedFile file = Request.Files[f]; file.SaveAs(Server.MapPath("~/images/") + file.FileName); Response.Write(hx);} 求解???????怎么回事?
求教问题 htmlunit报错
使用htmlunit的webclient 后报错Exception in thread "main" Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
WebClient循环DownLoadData
WebClient循环DownLoadData,有时超时有时直接停在那里不动了,十几分钟也不报错什么的。![图片说明](https://img-ask.csdn.net/upload/201611/08/1478574694_371386.png)![图片说明](https://img-ask.csdn.net/upload/201611/08/1478574683_970879.png)
c# WebClient下载问题
url结尾 input 就报错 换成结尾url txt zip rar 都是可以的.... string URLAddress = @"http://translate.google.cn/translate_tts?ie=UTF-8&q=你好&tl=zh-CN&total=1&idx=0&textlen=9&prev=input"; string receivePath = @"C:\"; System.Net.WebClient client = new System.Net.WebClient(); client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName(URLAddress));
【求助】webclient下载文件时 报System.Net.WebException: 操作超时”
``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; namespace SH600004Quickly { class Program { static void Main(string[] args) { WebClient webClient = new WebClient(); ServicePointManager.DefaultConnectionLimit = 100; string Start = "2010年04月13日"; string End = "2013年12月31日"; DateTime dtStart = DateTime.Parse(Start); DateTime dtEnd = DateTime.Parse(End); int Days = (dtEnd - dtStart).Days + 1;//相隔天数 string strPath = "F:\\gupiao111111\\"; string Stockid = "600000"; //string aFirstName = args[0].Substring(args[0].LastIndexOf("\\") + 1, (args[0].LastIndexOf(".") - args[0].LastIndexOf("\\") - 1)); for (int i = 0; i < Days; i++) { string url = null; string sDay = dtStart.AddDays(i).ToString("yyyy-MM-dd"); //每一天 url = "http://market.finance.sina.com.cn/downxls.php?date=" + sDay + "&symbol=sh" + Stockid; Console.WriteLine(url); DirectoryInfo stockDir = Directory.CreateDirectory(strPath + sDay); string dataDir = stockDir.FullName + "\\data.txt"; webClient.DownloadFile(url, dataDir); //webClient.Dispose(); //WriteStr2FileEnd("C:\\Users\\T.Yang\\Desktop\\errorLog.txt", sDay + " " + aFirstName); //strPath = "F:\\gupiao111111\\"; } //将每个文件夹里的文件用bat处理 } public static void WriteStr2FileEnd(String filename, String content)//自动换行写入 { FileStream fsLineNo = new FileStream(@filename, System.IO.FileMode.OpenOrCreate, FileAccess.Write); fsLineNo.Seek(fsLineNo.Length, SeekOrigin.Begin); StreamWriter swLineNo = new StreamWriter(fsLineNo); swLineNo.WriteLine(content); swLineNo.Close(); fsLineNo.Close(); } } } ``` 每次下载几个文件后,就卡在那不动了,怎么办?
WebClient 远程服务器返回错误: (401) 未经授权
使用C#写了一个简单的winform程序,想实现自动下载Reporting Service的报表。结果一直报错: System.Net.WebException: 远程服务器返回错误: (401) 未经授权。 ---> System.ComponentModel.Win32Exception: WebClient wc = new WebClient(); wc.DownloadFile(url,path) 报表服务器是内网,我直接再浏览器中打开地址 http://dbserver01/ReportServer/Pages/ReportViewer.aspx?spGetAuditingOrdersCount&Value1=2017/3/13&rs:Format=EXCEL ,就会直接导出文件,所以我想使用WebClient来下载,但是却报没有权限,不知道有没有解决办法。 网上查了好久,发现可能是权限问题,加了下面的语句,仍然报错 wc.Credentials = new NetworkCredential("software", "password", System.Environment.UserDomainName);
htmlunit模拟登录 请高人解答
使用htmlunit模拟登录的时候 ,首先穿创建了一个webclient 用webclient请求登录页面,同事请求解析验证码,验证码解析正确,然后开始登录系统,一直提示验证码错误。 WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_11); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient .getOptions().setUseInsecureSSL(true); WebRequest request1 = new WebRequest(new URL("http://rd2.zhaopin.com/s/loginmgr/login.asp")); HtmlPage htmlPage = webClient.getPage(request1); //第三步 获取界面元素 HtmlInput userName = htmlPage.getHtmlElementById("LoginName"); HtmlInput password = htmlPage.getHtmlElementById("Password"); HtmlInput checkCode = htmlPage.getHtmlElementById("CheckCode"); HtmlInput btn = htmlPage.getHtmlElementById("login"); WebRequest request = new WebRequest(new URL("https://passport.zhaopin.com/checkcode/imgrd")); UnexpectedPage imagePage = webClient.getPage(request); InputStream in = imagePage.getWebResponse().getContentAsStream(); File storeFile = new File("D:/zlzp.png"); BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(storeFile)); byte[] buf = new byte[2048]; int length = in.read(buf); while (length != -1) { output.write(buf, 0, length); length = in.read(buf); } in.close(); output.close(); String valCode = new OCR().recognizeText(new File("D:\\zlzp.png"), "png"); System.out.println(valCode); userName.setAttribute("value", ""); password.setAttribute("value", ""); checkCode.setAttribute("value", valCode); HtmlPage page2 = btn.click(); System.out.println("\n\n\n"); System.out.println(page2.asText());
htmlunit模拟登录 验证码错误
使用htmlunit模拟登录的时候 ,首先穿创建了一个webclient 用webclient请求登录页面,同事请求解析验证码,验证码解析正确,然后开始登录系统,一直提示验证码错误。 WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_11); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setCssEnabled(false); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient .getOptions().setUseInsecureSSL(true); WebWindow webWindow = webClient.getCurrentWindow(); WebRequest request1 = new WebRequest(new URL("http://rd2.zhaopin.com/s/loginmgr/login.asp")); HtmlPage htmlPage = webClient.getPage(webWindow,request1); String name = htmlPage.getWebClient().getWebWindows().get(0).getName(); System.out.println(name); //第三步 获取界面元素 HtmlInput userName = htmlPage.getHtmlElementById("LoginName"); HtmlInput password = htmlPage.getHtmlElementById("Password"); HtmlInput checkCode = htmlPage.getHtmlElementById("CheckCode"); HtmlInput btn = htmlPage.getHtmlElementById("login"); WebRequest request = new WebRequest(new URL("https://passport.zhaopin.com/checkcode/imgrd")); UnexpectedPage imagePage = webClient.getPage(webWindow,request); InputStream in = imagePage.getWebResponse().getContentAsStream(); File storeFile = new File("D:/zlzp.png"); BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(storeFile)); byte[] buf = new byte[2048]; int length = in.read(buf); while (length != -1) { output.write(buf, 0, length); length = in.read(buf); } in.close(); output.close(); String valCode = new OCR().recognizeText(new File("D:\\zlzp.png"), "png"); System.out.println(valCode); userName.setAttribute("value", ""); password.setAttribute("value", ""); checkCode.setAttribute("value", valCode); HtmlPage page2 = btn.click(); System.out.println("\n\n\n"); System.out.println(page2.asText());
WebClient UploadFile方法求教
public static void upLoad(string url, string path) { using (WebClient myWebClient = new WebClient()) { myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); byte[] responseArray = myWebClient.UploadFile(url, "POST", path); string msg = Encoding.GetEncoding("UTF-8").GetString(responseArray); if (msg.Contains("成功")) { Console.WriteLine("ok"); } } } 上传MP4文件 大小都在1m以内 有的电脑可以上传成功 而有的电脑却直接报错 实在是想不明白 求指点!
WebClient.DownloadData失败?
catch报An exception occurred during a WebClient request.错误 代码如下: string url=http://act.lexun.com/ztapp/Templates/release/cc1d2175_3506_44b2_be7a_b0add0bb5f5f.zip byte[] buffer = new WebClient { Credentials = CredentialCache.DefaultCredentials }.DownloadData(url); 这里直接跳到异常。 zip压缩包只有2M大小。
JAVA使用htmlunit中的activeX功能,但是jacob报错 Can't find moniker,如何解决?
htmlunit开启activeX ``` webClient.getOptions().setActiveXNative(true); ``` 会报错: ``` com.jacob.com.ComFailException: Can't find moniker at com.jacob.com.Dispatch.createInstanceNative(Native Method) at com.jacob.com.Dispatch.<init>(Dispatch.java:99) at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58) ``` 需要用到jacob.jar 项目目前导入1.19,JDK1.8,64位WIN10。 尝试过网上的更换32位JDK已及1.7JDK以及各个版本的jacob。 IE中的activeX能够正常使用,并且官网htmlunit官网示例中 ``` final ActiveXComponent activeXComponent = new ActiveXComponent("InternetExplorer.Application"); final boolean busy = activeXComponent.getProperty("Busy").getBoolean(); System.out.println(busy); ``` 也无问题。 但是在java代码中就是会报错Can't find moniker,网上也没查出个所以然来。 1. 初步判断跟htmlunit无关(错误信息是jacob初始化的时候的错误) 2. 跟jacob也无关(因为并不是所有的clsid在初始化时都会报错) 怀疑是dll的问题,但是个人并不懂dll,不清楚在什么情况下会导致jacob报错Can't find moniker。也尝试过Regsvr32注册,失败了。VC,VB的运行库也都有。也弄了个32位的Win10实验,也失败。反正网上各种都可能性的言论都试过了。 如果是因为dll编写的原因导致的,麻烦有大佬能告知一下是什么情况下会导致这个问题。 真心求教怎么解决这问题。。。脑壳痛啊
c#中WebClient重复发送请求的问题
wpf .net4.0环境, 我用按钮,点击执行下面的代码段,点击一次, 发送http请求到指定的url,这个url是我写的服务器端程序 但是为什么我只是点击了一次按钮,服务器端却收到两次同样的请求呢? 而我用ie浏览器的地址框发送同样的url到我的服务器,就是收到一次请求。 也就是说,WebClient会自动发送两次请求,这是什么原理? 如何解决呢? WebClient mo_client = new WebClient(); string ls_rst = string.Empty; try { StreamReader lo_sr = new StreamReader(mo_client.OpenRead(new Uri(url)), UTF8Encoding.UTF8); ls_rst = lo_sr.ReadToEnd(); lo_sr.Close(); lo_sr.Dispose(); lo_sr = null; } catch (Exception ex) { }
用WebClient类的DownLoadFile方法自动下载文件
asp.net中如何用WebClient类的DownLoadFile方法自动下载指定文件夹中不同类型文件到本地文件夹中,如何实现,求大神
WebClient 文件下载覆盖时提示文件被占用,有没有办法解决
``` WebClient Web = new WebClient(); Web.DownloadFile(URL, Client.BasePath + @"Plugins\" + b.Groups[5].Value); MessageBox.Show("下载成功!"); Web.Dispose(); ``` 如题
我用spring的webclient做文件下载的功能,下载的是一个zip文件,然后报出了?请大家帮帮忙,谢谢!
错误信息如下: org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'application/zip' not supported at org.springframework.web.reactive.function.BodyExtractors.lambda$readWithMessageReaders$20(BodyExtractors.java:254) at java.util.Optional.orElseGet(Optional.java:267) at org.springframework.web.reactive.function.BodyExtractors.readWithMessageReaders(BodyExtractors.java:250) at org.springframework.web.reactive.function.BodyExtractors.lambda$toMono$2(BodyExtractors.java:92) at org.springframework.web.reactive.function.client.DefaultClientResponse.body(DefaultClientResponse.java:87) at org.springframework.web.reactive.function.client.DefaultClientResponse.bodyToMono(DefaultClientResponse.java:109) at com.jeesite.modules.transmission.entity.Client.pull(Client.java:145) at com.jeesite.modules.transmission.service.TransmissionService.clientPull(TransmissionService.java:279) at com.jeesite.modules.sbos.utils.socket.SendServiceTest.testPull(SendServiceTest.java:105) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206) 我的代码是这样的: 发请求: ``` Mono<ClientResponse> resp = WebClient.create("http://" + this.url).get() .uri("/trans/pull/{busType}/{token}/{appUri}", busType, AesUtils.encode(Constant.TOKEN + "_" + System.currentTimeMillis(), Constant.TOKEN_KEY), this.appUri) .accept(MediaType.APPLICATION_OCTET_STREAM).exchange(); System.out.println("向http://" + this.url + "发送请求"); ClientResponse response = resp.block(); Resource resource = response.bodyToMono(Resource.class).block(); String pullFileDir = Global.getUserfilesBaseDir("pull_file_r"); FileUtils.createDirectory(pullFileDir); File out = new File(pullFileDir + File.separator + this.appUri + busType + ".zip"); try { FileUtils.copyInputStreamToFile(resource.getInputStream(), out); // 删除远端临时文件 WebClient webClient = WebClient.create("http://" + this.url); System.out.println("向http://" + this.url + "发送请求"); webClient.post().uri("/trans/clean_pull_file/{busType}/{token}/{appUri}", busType, AesUtils.encode(Constant.TOKEN + "_" + System.currentTimeMillis(), Constant.TOKEN_KEY), this.appUri) .retrieve().bodyToMono(String.class); } catch (IOException e) { e.printStackTrace(); } ``` 接收的controller: ``` /** * 拉取数据 * * @param busType * 业务类型 * @param token * 令牌 * @param appUri * 应用唯一标识 * @param request * 请求对象 * @param response * 响应对象 */ @GetMapping("pull/{busType}/{token}/{appUri}") public void pull(@PathVariable("busType") String busType, @PathVariable("token") String token, @PathVariable("appUri") String appUri, HttpServletRequest request, HttpServletResponse response) { String tempFileDir = Global.getUserfilesBaseDir("pull_file"); String tempFileName = appUri + busType + ".zip"; FileUtils.downFile(new File(tempFileDir + File.separator + tempFileName), request, response); } ```
关于c#使用WebClient调用openapi接口
使用c#调用openapi接口。如下图 ![图片说明](https://img-ask.csdn.net/upload/201703/06/1488785737_987974.jpg) java代码为: ``` public static PageResponse<UIMUser> userfind() { List<CommonCondition> conditions = new ArrayList<CommonCondition>(); CommonCondition c = new CommonCondition(); c.setName("userName"); c.setDataType(DataType.String); c.setCriteriaType(CriteriaType.StartWith); c.setValue("User1"); conditions.add(c); PostMethod method = new PostMethod(endPoint + "/admin/macula-uim/user/find"); try { method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); // 标识是OpenAPI请求 method.addRequestHeader(OpenApiUtils.AJAX_REQUEST_HEADER, OpenApiUtils.API_REQUEST_VALUE); // 添加POST BODY method.addParameter("page", "0"); method.addParameter("rows", "20"); method.addParameters(OpenApiUtils.getPostParams("conditions", conditions)); // 设置请求参数 method.setQueryString(OpenApiUtils.getOpenApiParams(appKey, appSecret, null, null, null, null, "zh_CN", method.getParameters())); int status = client.executeMethod(method); String content = method.getResponseBodyAsString(); if (status == HttpServletResponse.SC_OK || status == HttpServletResponse.SC_INTERNAL_SERVER_ERROR) { // 反序列化结果 ObjectMapperImpl mapper = new ObjectMapperImpl(); return mapper.readValue(content, new TypeReference<PageResponse<UIMUser>>() { }); } else { throw new Exception("错误的请求"); } } catch (Exception e) { e.printStackTrace(); } finally { method.releaseConnection(); } return null; } public static NameValuePair[] getPostParams(String objectName, Object obj) { List<NameValuePair> pairs = new ArrayList<NameValuePair>(); if (obj != null) { if (obj instanceof Map) { // 处理Map Map<?, ?> map = (Map<?, ?>) obj; for (Map.Entry<?, ?> entry : map.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); if (null != value) { pairs.addAll(Arrays.asList(getPostParams(objectName + "['" + key + "']", value))); } } } else if (obj instanceof Collection) { // 处理Collection Collection<?> col = (Collection<?>) obj; Iterator<?> it = col.iterator(); int index = 0; while (it.hasNext()) { Object value = it.next(); if (null != value) { pairs.addAll(Arrays.asList(getPostParams(objectName + "[" + index++ + "]", value))); } } } else if (!BeanUtils.isSimpleProperty(obj.getClass()) && !(obj instanceof Enum) && !Date.class.isAssignableFrom(obj.getClass())) { // 处理Bean BeanWrapperImpl bean = new BeanWrapperImpl(obj); PropertyDescriptor[] ps = bean.getPropertyDescriptors(); for (PropertyDescriptor p : ps) { if (!p.getName().equals("class")) { Object value = bean.getPropertyValue(p.getName()); if (null != value) { pairs.addAll(Arrays.asList(getPostParams(objectName + "." + p.getName(), value))); } } } } else { String str = obj.toString(); // 处理简单属性 // 日期格式使用ISO8601 if (obj instanceof Date) { str = DateFormatUtils.formatISO8601((Date) obj); } pairs.add(new NameValuePair(objectName, str)); } } return pairs.toArray(new NameValuePair[pairs.size()]); } ``` 现在不清楚使用c#怎么传递第一个参数。 我自己写的代码: ``` using (WebClient client = new WebClient()) { //SyncOrgDAL dal = new SyncOrgDAL(); // List<CommonCondition> conditions = new List<CommonCondition>(); //CommonCondition c = new CommonCondition(); //c.setName("userType"); //c.setDataType(DataType.String); //c.setCriteriaType(CriteriaType.Equals); //c.setValue("User1"); //conditions.Add(c); NameValueCollection postParams = new NameValueCollection { { "conditions", "[\"conditions\":{\"UserName\":\"Exp\",\"userType\":\"Exp\"}]" }, { "page", page.ToString() }, { "rows", pagesize.ToString() } }; //NameValueCollection postParams = new NameValueCollection { { "fromId", "302264246" }, { "toId", "99999999999" } }; string passString = Parameters.GetOpenApiParams(account, passWord, null, null, null, null, "zh_CN", postParams); //passString += "&userType=EMP"; url += passString; client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); client.Headers.Add("X-Requested-With", "OpenAPIRequest"); client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0"); try { byte[] rDownData = client.UploadValues(url, "POST", postParams); var downString = Encoding.UTF8.GetString(rDownData) ?? ""; return downString; } catch (Exception ex) { return ex.ToString(); } finally { client.Dispose(); GC.Collect(); } ``` NameValueCollection postParams = new NameValueCollection { { "conditions", "[\"conditions\":{\"UserName\":\"Exp\",\"userType\":\"Exp\"}]" }, { "page", page.ToString() }, { "rows", pagesize.ToString() } }; 第一个参数什么格式。
WebClient抓不到网页内容
static void Main(string[] args) { WebClient MyWebClient = new WebClient(); MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据 Byte[] pageData = MyWebClient.DownloadData("http://detail.zol.com.cn/index.php?c=SearchList&keyword=联想"); //从指定网站下载数据 string pageHtml = Encoding.Default.GetString(pageData); //如果获取网站页面采用的是GB2312,则使用这句 //string pageHtml = Encoding.UTF8.GetString(pageData); //如果获取网站页面采用的是UTF-8,则使用这句 Console.WriteLine(pageHtml);//在控制台输入获取的内容 Console.Read(); }
关于 webclient UploadFile 导致的401 错误
本人想实现通过webclient 的uploadFile 给 IIs网站的某个目录下 ** 匿名** 上传文档 但是 一直返回 401 错误(**远程服务器返回错误: (401) 未经授权。**) ,结果,返回“远程服务器返回错误: (401) 未经授权。”的错误,然后百度 谷歌 折腾了两天,还是没有头绪,希望大家帮我看看,为了简化问题,我把问题聚焦到一段代码里,方便大家黏贴测试。 Imports System.Net Public Class Form1 Private WithEvents wcFileUploadClient As WebClient Private Const strServerIP As String = "10.21.61.141" Private RemoteDIR As String = "http://" & strServerIP & "/DrugRehabilitation/ExptData/" & "PPT" & "/" Private RemoteURLPath As String = "" Private LocalDiskPath As String = "D:\hsrv.txt" Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click wcFileUploadClient = New WebClient RemoteURLPath = RemoteDIR wcFileUploadClient.UploadFile(RemoteURLPath, "PUT", LocalDiskPath) '**这句话出现401错误** End Sub End Class ``` ``` 我目前使用的服务器是2008 server R2(IIS7.5) 目前在IIS 我已经做了如下的配置 webDAv已经打开 ![图片说明](https://img-ask.csdn.net/upload/201708/06/1502020067_554725.png) 目录浏览已经打开 ![图片说明](https://img-ask.csdn.net/upload/201708/06/1502020099_308533.png) 匿名身份验证已经打开 ![图片说明](https://img-ask.csdn.net/upload/201708/06/1502020126_166682.png) 文件夹IIS-IUSERs属性已经设置过了 ![图片说明](https://img-ask.csdn.net/upload/201708/06/1502020175_883421.png) 但是,还是不行,希望大家帮忙看一下
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
英特尔不为人知的 B 面
从 PC 时代至今,众人只知在 CPU、GPU、XPU、制程、工艺等战场中,英特尔在与同行硬件芯片制造商们的竞争中杀出重围,且在不断的成长进化中,成为全球知名的半导体公司。殊不知,在「刚硬」的背后,英特尔「柔性」的软件早已经做到了全方位的支持与支撑,并持续发挥独特的生态价值,推动产业合作共赢。 而对于这一不知人知的 B 面,很多人将其称之为英特尔隐形的翅膀,虽低调,但是影响力却不容小觑。 那么,在...
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
刷了几千道算法题,这些我私藏的刷题网站都在这里了!
遥想当年,机缘巧合入了 ACM 的坑,周边巨擘林立,从此过上了"天天被虐似死狗"的生活… 然而我是谁,我可是死狗中的战斗鸡,智力不够那刷题来凑,开始了夜以继日哼哧哼哧刷题的日子,从此"读题与提交齐飞, AC 与 WA 一色 ",我惊喜的发现被题虐既刺激又有快感,那一刻我泪流满面。这么好的事儿作为一个正直的人绝不能自己独享,经过激烈的颅内斗争,我决定把我私藏的十几个 T 的,阿不,十几个刷题网...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
【图解经典算法题】如何用一行代码解决约瑟夫环问题
约瑟夫环问题算是很经典的题了,估计大家都听说过,然后我就在一次笔试中遇到了,下面我就用 3 种方法来详细讲解一下这道题,最后一种方法学了之后保证让你可以让你装逼。 问题描述:编号为 1-N 的 N 个士兵围坐在一起形成一个圆圈,从编号为 1 的士兵开始依次报数(1,2,3…这样依次报),数到 m 的 士兵会被杀死出列,之后的士兵再从 1 开始报数。直到最后剩下一士兵,求这个士兵的编号。 1、方...
吐血推荐珍藏的Visual Studio Code插件
作为一名Java工程师,由于工作需要,最近一个月一直在写NodeJS,这种经历可以说是一部辛酸史了。好在有神器Visual Studio Code陪伴,让我的这段经历没有更加困难。眼看这段经历要告一段落了,今天就来给大家分享一下我常用的一些VSC的插件。 VSC的插件安装方法很简单,只需要点击左侧最下方的插件栏选项,然后就可以搜索你想要的插件了。 下面我们进入正题 Material Theme ...
如何防止抄袭PCB电路板
目录 1、抄板是什么 2、抄板是否属于侵权 3、如何防止抄板 1、抄板是什么 抄板也叫克隆或仿制,是对设计出来的PCB板进行反向技术研究;目前全新的定义:从狭义上来说,抄板仅指对电子产品电路板PCB文件的提取还原和利用文件进行电路板克隆的过程;从广义上来说,抄板不仅包括对电路板文件提取、电路板克隆、电路板仿制等技术过程,而且包括对电路板文件进行修改(即改板)、对电子产品外形模具进行三维...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
Python 植物大战僵尸代码实现(2):植物卡片选择和种植
这篇文章要介绍的是: - 上方植物卡片栏的实现。 - 点击植物卡片,鼠标切换为植物图片。 - 鼠标移动时,判断当前在哪个方格中,并显示半透明的植物作为提示。
相关热词 基于c#波形控件 c# 十进制转十六进制 对文件aes加密vc# c#读取栈中所有的值 c# rsa256加密 好 学c# 还是c++ c# 和java的差距 c# curl网络框架 c# https证书请求 c# 中崎
立即提问