跪求VB获取网页源码的极速方法,关键是速度一定要快
跪求VB获取网页源码的极速方法,关键是速度一定要快,VB实现,望各位高手贴出代码,速度一定要快哦...
跪求VB获取网页源码的极速方法,关键是速度一定要快,VB实现,望各位高手贴出代码,速度一定要快哦
展开
2个回答
展开全部
调用方法是
u = "http://www.baidu.com/"
Text1.Text = GetBody(u)'最好用richbox富文本框
'如果出现乱码,UTF-8可改为GB2312
Public Function GetBody(ByVal URL$, Optional ByVal Coding$ = "UTF-8")
Dim ObjXML
On Error Resume Next
Set ObjXML = CreateObject("Microsoft.XMLHTTP")
With ObjXML
.Open "Get", URL, False, "", ""
.setRequestHeader "If-Modified-Since", "0"
.Send
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody, Coding)
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
u = "http://www.baidu.com/"
Text1.Text = GetBody(u)'最好用richbox富文本框
'如果出现乱码,UTF-8可改为GB2312
Public Function GetBody(ByVal URL$, Optional ByVal Coding$ = "UTF-8")
Dim ObjXML
On Error Resume Next
Set ObjXML = CreateObject("Microsoft.XMLHTTP")
With ObjXML
.Open "Get", URL, False, "", ""
.setRequestHeader "If-Modified-Since", "0"
.Send
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody, Coding)
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询