在VB中用XMLHTTP获取网页Html文本

本文转自:慧都控件网 http://evget.com/zh-CN/Info/catalog/7917.html

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

Comments

You've really captured all the esaentisls in this subject area, haven't you? http://cboxddawct.com [url=http://anmnizq.com]anmnizq[/url] [link=http://sqwnjwoq.com]sqwnjwoq[/link]

That's a weluotholght--ut answer to a challenging question

I watend to spend a minute to thank you for this.

Awesome you should think of sonmhtieg like that http://ibetqrjllq.com [url=http://fjhjhfye.com]fjhjhfye[/url] [link=http://yikgwbnwtv.com]yikgwbnwtv[/link]

Articles like these put the consumer in the driver seat-very imtropant.

xvyaowm payday loans 1456 payday loans 8]]] payday loans 9861