当前位置:中国站长下载文章中心数据库区ACCESS → 数据库学习:用Access分析网站实例

数据库学习:用Access分析网站实例

减小字体 增大字体 作者:佚名  来源:不详  发布时间:2006-5-9 16:00:22
i As Long
Dim iA As Long
iA = rs.RecordCount

Do Until rs.EOF
If blnStop = True Then Exit Function
If strAdd1 <> rs("add") Then
strSql = "update ipaddress_ok set ip2='" & strIP1 & " ',enip2=" & Str(lngENIP1) & ",mark='' where mark='setting'"
CurrentProject.Connection.Execute strSql
DoEvents
strSql = "insert into ipaddress_ok (ip1,enip1,[mark],[add]) values('" & rs("ip1") & "'," & Str(rs("enip")) & ",'setting','" & rs("add") & "')"
CurrentProject.Connection.Execute strSql
DoEvents
End If

strAdd1 = rs("add")
strIP1 = rs("ip1")
lngENIP1 = rs("enip")
i = i + 1


Form_控制.Label4.Caption = Str(Int(i / iA * 10000) / 100) & "%"
rs.MoveNext
Loop
rs.Close

strSql = "update ipaddress_ok set ip2=mid(ip2,1,len(ip2)-2) & '255'"
CurrentProject.Connection.Execute strSql
strSql = "update ipaddress_ok set enip1=enaddr(ip1)"
CurrentProject.Connection.Execute strSql
strSql = "update ipaddress_ok set enip2=enaddr(ip2)"
CurrentProject.Connection.Execute strSql
End Function

Function enaddr(Sip As String) As Double
'用代理无法连接的问题还要解决
'将字符的 IP 编码为长整的 IP
On Error Resume Next
Dim str1 As String
Dim str2 As String
Dim str3 As String
Dim str4 As String
Sip = CStr(Sip)
str1 = Left(Sip, CInt(InStr(Sip, ".") - 1))
Sip = Mid(Sip, CInt(InStr(Sip, ".")) + 1)
str2 = Left(Sip, CInt(InStr(Sip, ".")) - 1)
Sip = Mid(Sip, CInt(InStr(Sip, ".")) + 1)
str3 = Left(Sip, CInt(InStr(Sip, ".")) - 1)
str4 = Mid(Sip, CInt(InStr(Sip, ".")) + 1)
enaddr = CLng(str1) * 256 * 256 * 256 + CLng(str2) * 256 * 256 + CLng(str3) * 256 + CLng(str4) - 1
End Function

Function deaddr(Sip)
'将编码为长整的 IP 重现转换为字符型的 IP
Dim s1, s21, s2, s31, s3, s4
Sip = Sip + 1
s1 = Int(Sip / 256 / 256 / 256)
s21 = s1 * 256 * 256 * 256
s2 = Int((Sip - s21) / 256 / 256)
s31 = s2 * 256 * 256 + s21
s3 = Int((Sip - s31) / 256)
s4 = Sip - s3 * 256 - s31
deaddr = CStr(s1) + "." + CStr(s2) + "." + CStr(s3) + "." + CStr(s4)
End Function

示例请参考:http://access911.net/down/eg/User_DHTML_search_IP.rar

上述程序会自动去 http://ip.loveroot.com/index.php?job=search 搜索所有的 IP 以及对应的物理地址并保存到中

修订:刚才上了一下网站,发现界面竟然改了,又重新修改了一下读取页面的程序。

关于 WebBrowser 控件的资料请参考 VB6 中 MSDN 的以下章节
Internet Client SDK
Internet Tools & Technologies
Reusing the WebBrowser and MSHTML

inet401/help/itt/ieprog/IEProg.htm#book_browsing(BOOKMARK)

  

上一页  [1] [2]