您的位置:首页 > 编程语言 > VB

VB自动登录检测并添加域名

2010-02-19 02:15 239 查看
郁闷,我使用的这个空间的IDC商竟然每隔一段时间就要检测绑定的域名是否再未提交备案列表中,如果是就删除,但是却不检测我是否提交了备案,按照他们说法删除域名一天后才能再次绑定,否则这一天内绑定了到下次检测就会再删除。这样我就不停的在后台看,看是否被删除,如果被删除,就再把域名绑定上去,;(很受伤!
于是用VB做了个程序,自动登录检测,看域名是否被删除,删除则自动添加域名上去,每10秒检测一次。主要用到了WebBrowser
新建窗体FORM1,在窗体上建个WebBrowser和TIMER就可以了,TIMER间隔设置为10000。
以下是代码

Private Sub Form_Load()
WebBrowser1.Navigate "http://**************/hostadm/subhostname1.asp?id=****"
End Sub

Private Sub Timer1_Timer()
WebBrowser1.Refresh
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
turl = WebBrowser1.LocationURL
If turl <> "http://**************/hostadm/subhostname1.asp?id=****" Then
If turl <> "http://**************/user/default.asp" Then
If turl <> "http://**************/user/logininfo.asp" And turl <> "http://**************/user/hostadm.asp" And turl <> "http://**************/hostadm/selfhostmodify.asp" Then
WebBrowser1.Navigate "http://**************/user/default.asp"
ElseIf turl = "http://**************/hostadm/selfhostmodify.asp" Then
WebBrowser1.Navigate "http://**************/hostadm/subhostname1.asp?id=****"
ElseIf turl = "http://**************/user/hostadm.asp" Then
WebBrowser1.Navigate "http://**************/user/hostadm2.asp?id=****&go=a"
Else
WebBrowser1.Navigate "http://**************/user/hostadm.asp"
End If
Else
For Each yhx In WebBrowser1.Document.All
If yhx.tagname = "INPUT" Then
If yhx.Name = "username" Then
yhx.Value = "****"
End If
If yhx.Name = "password" Then
yhx.Value = "*****"
End If
If yhx.Type = "image" Then
yhx.Click
End If
End If
Next
End If
Else
neirong = WebBrowser1.Document.Body.innerText
If InStr(neirong, "blog.denglijun.tw") = 0 Then
For Each yhx In WebBrowser1.Document.All
If yhx.tagname = "INPUT" Then
If yhx.Name = "hostname3" Then
yhx.Value = "blog.denglijun.tw"
End If
End If
Next
WebBrowser1.Document.modhostname.submit
writelog "yes"
End If

End If
End Sub

Private Sub writelog(ByVal mylogs As String)
Set fso = CreateObject("Scripting.FileSystemObject")
Set tf = fso.OpenTextFile(App.Path & "/login.log", 8, True)
tf.WriteLine (Now() & "  " & mylogs)
tf.Close
End Sub

其次我要找个电脑一直开着来运行这个程序了,因为我才把BLOG提交到搜索引擎,可不希望蜘蛛来爬的时候是域名未绑定哦。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: