7,763
社区成员
发帖
与我相关
我的任务
分享
Public Const JiLiangGuanLiXiTong = "http://10.67.132.33/"
Function OpenJiLiangXiTong(name As String, mima As String) As String '自动登录子程序
Dim vDoc, vTag
Dim i As Integer
Dim browser As Object, timeie As Date
Set browser = CreateObject("InternetExplorer.application")
browser.Visible = True
browser.Navigate (JiLiangGuanLiXiTong)
timeie = DateAdd("s", 60, Now()) '等待60s
Do While browser.Busy And Not browser.ReadyState = False
DoEvents
If timeie < Now() Then
MsgBox "网络不通!", vbInformation, "网络不通"
browser.Quit
Exit Function
End If
Loop
Set vDoc = browser.Document
For i = 0 To vDoc.All.Length - 1
If UCase(vDoc.All(i).tagName) = "INPUT" Then
Set vTag = vDoc.All(i)
If vTag.Type = "text" Or vTag.Type = "password" Then
Select Case vTag.name
Case "Username"
vTag.Value = name
Case "Password"
vTag.Value = mima
End Select
ElseIf vTag.Type = "image" Then
vTag.Select
vTag.Click
End If
End If
Next i
End Function
Dim xPost, sGet As Object
Dim iRemote, sendstr, tempAs String
Dim k As Integer
Set xPost = CreateObject("Microsoft.XMLHTTP")
Set sGet = CreateObject("ADODB.Stream")
iRemote = "http://10.67.132.33/"
sendstr = "Username=" & name & "Password=" & mima
xPost.Open "post", iRemote, False
xPost.setRequestHeader "Accept", "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
xPost.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xPost.setRequestHeader "Accept-Language", "zh-cn"
xPost.setRequestHeader "Accept-Encoding", "gzip, deflate"
xPost.setRequestHeader "Referer", "http://10.67.132.33/"
xPost.send (sendstr)
If xPost.readyState = 4 Then
If xPost.Status = 200 Then
sGet.mode = 3
sGet.Type = 1
sGet.Open
sGet.Write (xPost.responseBody)
sGet.Position = 0
sGet.Type = 2
sGet.charset = "gb2312" ' "gb2312"
temp = sGet.ReadText '返回的网页
end if
end if