关于XMLHTTP的运用(分数大赠送,不够可以再加)

liangzhg 2002-07-20 09:30:23
用这个组件在www.net.cn得到的是乱码,请问如何解决?或者谁有更好的中文域名查询程序??很急的!!高分赠送。
...全文
74 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
daehappy 2002-07-21
  • 打赏
  • 举报
回复
up!gz!
nittystone 2002-07-20
  • 打赏
  • 举报
回复
这篇文章对我帮助很大
鸣谢!
是dev-club的 zee 写的。
evonne_feng 2002-07-20
  • 打赏
  • 举报
回复
刚得到结果,从网上找到的!

在VB中用下面的函数BytesToString(oXMLHttp.responseBody)就可以得到正常的内容了

Function BytesToString(vIn As Variant) As String

Dim i As Integer, thisCharCode As Integer, nextCharCode As Integer
Dim sReturn As String
sReturn = ""
For i = 1 To LenB(vIn)
thisCharCode = AscB(MidB(vIn, i, 1))
If thisCharCode < &H80 Then
sReturn = sReturn & Chr(thisCharCode)
Else
nextCharCode = AscB(MidB(vIn, i + 1, 1))
sReturn = sReturn & Chr(CLng(thisCharCode) * &H100 + CInt(nextCharCode))
i = i + 1
End If
Next
BytesToString = sReturn

End Function
liangzhg 2002-07-20
  • 打赏
  • 举报
回复
我知道那个函数怎么改,问题是我改改过以后还是不行,返回的结果什么也没有。各位帮帮忙。
evonne_feng 2002-07-20
  • 打赏
  • 举报
回复
把你的代码贴出来看看
ar7_top 2002-07-20
  • 打赏
  • 举报
回复
学习学习

收藏收藏
evonne_feng 2002-07-20
  • 打赏
  • 举报
回复
BytesToString函数在VB中测试通过,但在asp中好像有点问题,我正在调试,如果不行,建议用vb写一个com,在asp中调用
evonne_feng 2002-07-20
  • 打赏
  • 举报
回复
BytesToString函数是在VB中使用的,你直接在asp中使用当然出错,再asp中这样用:
On Error Resume Next
Dim Retrieval
Dim Domain
Dim TakenHTML

Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = BytesToString(.ResponseText)
End With
Set Retrieval = Nothing
End Function

Function BytesToString(vIn)

Dim i , thisCharCode , nextCharCode
Dim sReturn

sReturn = ""
For i = 1 To LenB(vIn)
thisCharCode = AscB(MidB(vIn, i, 1))
If thisCharCode < &H80 Then
sReturn = sReturn & Chr(thisCharCode)
Else
nextCharCode = AscB(MidB(vIn, i + 1, 1))
sReturn = sReturn & Chr(CLng(thisCharCode) * &H100 + CInt(nextCharCode))
i = i + 1
End If
Next
BytesToString = sReturn

End Function

TakenHTML = GetURL("http://www.net.cn/has_client/whois.asp?domain=asdfafdsa&tld=com")
Response.Write takenhtml
nittystone 2002-07-20
  • 打赏
  • 举报
回复
<%
on error resume next
Dim Retrieval
Dim Domain
Dim TakenHTML
Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = BytesToString(.ResponseBody)
End With
Set Retrieval = Nothing
End Function


TakenHTML = GetURL("http://www.net.cn/has_client/whois.asp?domain=asdfafdsa&tld=com")
Response.Write takenhtml
Function BytesToString(vIn As Variant) As String

Dim i As Integer, thisCharCode As Integer, nextCharCode As Integer
Dim sReturn As String
sReturn = ""
For i = 1 To LenB(vIn)
thisCharCode = AscB(MidB(vIn, i, 1))
If thisCharCode < &H80 Then
sReturn = sReturn & Chr(thisCharCode)
Else
nextCharCode = AscB(MidB(vIn, i + 1, 1))
sReturn = sReturn & Chr(CLng(thisCharCode) * &H100 + CInt(nextCharCode))
i = i + 1
End If
Next
BytesToString = sReturn

End Function

%>
这是一个简化了的东西,输出的结果是乱码,用上面的程序就什么都的不到了
liangzhg 2002-07-20
  • 打赏
  • 举报
回复
<%
on error resume next
Dim Retrieval
Dim Domain
Dim TakenHTML
Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = .ResponseText
End With
Set Retrieval = Nothing
End Function


End Function

TakenHTML = GetURL("http://www.net.cn/has_client/whois.asp?domain=asdfafdsa&tld=com")
Response.Write takenhtml
%>
这是一个简化了的东西,输出的结果是乱码,用上面的程序就什么都的不到了
liangzhg 2002-07-20
  • 打赏
  • 举报
回复
Dim Retrieval
Dim Domain
Dim TakenHTML
Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = .ResponseText
End With
Set Retrieval = Nothing
End Function
TakenHTML = GetURL("http://www.net.cn/has_client/whois.asp?domain="这里写要查询的域名"&tld="域名类型"")
Response.Write BytesToString(TakenHtml)

28,391

社区成员

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

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