vb 用 xmlhttp 获取网站信息

前端之家收集整理的这篇文章主要介绍了vb 用 xmlhttp 获取网站信息前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Public Function GetCode(CodeBase,Url) '第一个参数是设置编码方式(GB2312或UTF-8)第二个参数是地址.
Dim xmlHTTP1
Set xmlHTTP1 = CreateObject("Microsoft.XMLHTTP")
xmlHTTP1.Open "get",Url,True
xmlHTTP1.send
While xmlHTTP1.ReadyState <> 4
DoEvents
Wend
GetCode = xmlHTTP1.ResponseBody
If CStr(GetCode) <> "" Then GetCode = BytesToBstr(GetCode,CodeBase)
Set ObjXML = Nothing
End Function

Public Function BytesToBstr(strBody,CodeBase)
Dim ObjStream
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.write strBody
.Position = 0
.Type = 2
.Charset = CodeBase
BytesToBstr = .ReadText
.Close
End With
Set ObjStream = Nothing
End Function

Private Sub Command1_Click()
Dim aa As String
aa = GetCode("GB2312","http://www.2288822.net") RichTextBox1.Text = aaEnd Sub

原文链接:https://www.f2er.com/vb/261412.html

猜你在找的VB相关文章