码迷,mamicode.com
首页 > 其他好文 > 详细

11111

时间:2015-03-12 20:49:06      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:

返回值 = 获得网页源文件("http://www.cnblogs.com/huangliang72/p/4333233.html")
TracePrint 返回值
MessageBox 返回值

//
//Function 获取(IP,IP地名)
// Call 获取(IP,IP地名)
//TracePrint IP
//TracePrint IP地名
//地址内容 = lib.网络.获得网页源文件("http://ip138.com")
//查找前 = inStr(地址内容,"src=") + 5
//查找后 = inStr(地址内容,"rel=") - 查找前-2
//IP网页地址 = Mid(地址内容, 查找前, 查找后)
//得到网页 = lib.网络.获得网页源文件(IP网页地址)
//二次查找前 = inStr(得到网页,"[") + 1
//二次查找后 = inStr(得到网页,"]") - 二次查找前
//IP = Mid(得到网页, 二次查找前, 二次查找后)
//三次查找前 = inStr(得到网页,"来自") + 3
//三次查找后 = inStr(得到网页,"</cen") - 三次查找前
//IP地名 = Mid(得到网页, 三次查找前, 三次查找后)
//End Function
//
//VBSBegin
// Set obj = GetObject("winmgmts:\\.\root\cimv2")
// Set IPConfigSet = obj.ExecQuery ("Select IPAddress from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
// For Each IPConfig in IPConfigSet
// If Not IsNull(IPConfig.IPAddress) Then
// For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
// add = IPConfig.IPAddress(i)
// MessageBox(add)
// Next
// End If
// Next
//VBSEnd
Function 获得网页源文件(网页地址)
//说明:支持远程获取文本内容,如:MsgBox lib.网络.获得网页源文件("http://www.anjian.com/test.txt")
//例子:MsgBox lib.网络.获得网页源文件("http://www.anjian.com")
Dim xmlHttp, xmlBody, xmlUrl
Dim ThisCharCode ,NextCharCode ,BytesToBstr
If InStr(网页地址, "http://") = 0 Then
xmlUrl = "http://" & 网页地址
Else
xmlUrl = 网页地址
End if
Set xmlHttp = CreateObject("Microsoft.XMLHTTP")
xmlHttp.Open "Get", xmlUrl, False
xmlHttp.Send
xmlBody = xmlHttp.ResponseBody
Set xmlHttp = Nothing
获得网页源文件 = ""
If Len(xmlBody) = 0 Then Exit Function
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.Write xmlBody
.Position = 0
.Type = 2
.Charset = "UTF-8"
BytesToBstr = .ReadText
.Close
End With
Set ObjStream = Nothing
获得网页源文件 = BytesToBstr
End Function

11111

标签:

原文地址:http://www.cnblogs.com/huangliang72/p/4333293.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!