使用 MSXML2.XMLHTTP时 遇到的一个问题

blueonly 2005-12-12 04:07:04
用下列代码获取网页的html,可是用着用着就会出现卡死的情况,即一直都不返回程序停在那不动了

也不报错

这可能是什么原因,应该怎么解决?

private function getBody(surl)
'获取URL的HTML代码
dim xmlHttp
set xmlHttp=server.createobject("MSXML2.XMLHTTP")
xmlHttp.open "GET",surl,false
xmlHttp.send
if xmlHttp.readystate<>4 then
getBody=""
set xmlHttp=nothing
exit function
end if
getBody=xmlhttp.responsebody
set xmlHttp=nothing
end function
...全文
726 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
epjack 2006-01-09
  • 打赏
  • 举报
回复
http://www.wewill.cn/default.asp?action=article&ID=216
blueonly 2006-01-08
  • 打赏
  • 举报
回复
up :D
lliei 2006-01-05
  • 打赏
  • 举报
回复
<%
Function GetHTTPPage(url)
Response.Write url & "<p>"
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "get", url, False
.Send
GetHTTPPage = .responseText
End With
Set Retrieval = Nothing
End Function


wstr=getHTTPPage("http://search.half.ebay.com/ws/web/HalfSearch?m=books&submit=Search&isbn=0619268158")
response.write wstr
%>

我怎么拿不到这个网页阿,帮我看一下吧,谢谢阿
blueonly 2005-12-19
  • 打赏
  • 举报
回复
up -_-b
blueonly 2005-12-16
  • 打赏
  • 举报
回复
用下列代码获取网页的html,可是用着用着就会出现卡死的情况,即一直都不返回程序停在那不动了,我知道许多人遇到这中情况,可以排除程序脚本的错误,
虽然后台我已用serverxmlhttp + settimeout解决了问题
但是 这到底是什么原因造成的 ?
blueonly 2005-12-16
  • 打赏
  • 举报
回复
谢谢上面给出的信息
再重申一下问题

我的代码是用在服务器端运行的,后台我在查看MSXML4 sdk时
发现有另一个对象serverxmlhttp,简单看了介绍发现其实应该用着个声明,可是在网上看的许多小偷程序确用的是 microsoft.xmlhttp ,并且很多人多讨论发生死锁的现象.
是不是由于用错了对象?改用serverxmlhttp就好了?

_______________________
The HTTP client stack offers longer uptimes. WinInet features that are not critical for server applications, such as URL caching, auto-discovery of proxy servers

这句话意味着serverxmlhttp 不支持URL caching和auto-discovery of proxy servers?
jspadmin 2005-12-15
  • 打赏
  • 举报
回复
我也的好好补补xml课了,惭愧
孟子E章 2005-12-15
  • 打赏
  • 举报
回复
参考

http://www.kbalertz.com/kbNamed_872788/Fixes.problem.that.causes.waitForResponse.method.ServerXMLHTTP.class.fail.when.there.redirect.request.another.Contains.hotfix.this.aspx
孟子E章 2005-12-15
  • 打赏
  • 举报
回复
http://support.microsoft.com/kb/290761/zh-cn
孟子E章 2005-12-15
  • 打赏
  • 举报
回复
serverxmlhttp功能与xmlhttp类似,但SServerXmlhttp更安全,也扩充了功能,如超时
getOption, setOption, waitForResponse, and setTimeouts等
可参考
http://msdn.microsoft.com/library/en-us/xmlsdk/html/7e91f3de-d21c-404d-966a-95c148b22e98.asp
blueonly 2005-12-15
  • 打赏
  • 举报
回复
serverxmlhttp 是xmlhttp的一个替代对象吗?他们的关系是什么?
blueonly 2005-12-15
  • 打赏
  • 举报
回复
我的代码是用在服务器端运行的,后台我在查看MSXML4 sdk时
发现有另一个对象serverxmlhttp,简单看了介绍发现其实应该用着个声明,可是在网上看的许多小偷程序确用的是 microsoft.xmlhttp ,并且很多人多讨论发生死锁的现象.
是不是由于用错了对象?改用serverxmlhttp就好了?

_______________________
The HTTP client stack offers longer uptimes. WinInet features that are not critical for server applications, such as URL caching, auto-discovery of proxy servers

这句话意味着serverxmlhttp 不支持URL caching和auto-discovery of proxy servers?
victor888 2005-12-14
  • 打赏
  • 举报
回复
这类问题不提供URL是无法解决的。
lisoon 2005-12-13
  • 打赏
  • 举报
回复
if xmlhttp.status=200 then
getBody=xmlhttp.responsebody
else
'连接失败
end if
tigerwen01 2005-12-13
  • 打赏
  • 举报
回复
if xmlHttp.readystate<>4 then
getBody=""
set xmlHttp=nothing
exit function
end if
去掉上面那段代码试试,看是不是问题出在这里。
  • 打赏
  • 举报
回复
到我的网站上找找看

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧