作者:mervin
组织:黑色反击 http://www.hf110.com
网上有DELHPI版本的了,动画也有。有人在QQ上跟我要VB版本的,就写出来。 比较乱因为临时写的所以没有仔细调整还请见谅。
我用的是Inet1.Execute大家可以用OpenURL更加简单,几行代码就可以搞定。
Private Sub cmdcx_Click()
Dim s As String
s = LTrim(txturl.Text)
On Error Resume Next
Inet1.Execute "http://data.alexa.com/data?cli=10&dat=snba&url=" & s, "get"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim web
Dim lsbl
Dim wz
If State = 11 Then
MsgBox "电脑未连接网络或出现未知错误,请关闭程序重试!", , "错误提示"
ElseIf State = 12 Then
Do '开始接受数据
DoEvents
lsbl = Inet1.GetChunk(1024, icString)
If Len(lsbl) = 0 Then Exit Do
web = web & lsbl
Loop
wz = InStr(1, web, "<POPULARITY URL=")
If wz = 0 Then
MsgBox "无该网站排名信息", , "提示信息"
Exit Sub
Else
web = Right(web, Len(web) - wz)
wz = InStr(1, web, "TEXT=")
End If
web = Right(web, Len(web) - (wz + 5))
wz = InStr(1, web, """")
web = Left(web, wz - 1)
txtpm.Text = web
End If
End Sub
最终效果图:
