|
楼主 |
发表于 2015-5-15 18:08
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
VBA万岁 发表于 2015-5-15 16:59
方便上传你的代码码? - Sub 添加新的端口()
- Dim objwinhttp As Object
- Dim objxmlhttp As Object
- Dim doc As MSHTML.HTMLDocument
- Dim aar() As String
- Dim filter As String
- Dim fileToOpen
- Dim URL As String
- Dim userhd() As String
- Dim newdslamid As String
- Dim Regex As Object
- Set Regex = CreateObject("VBScript.RegExp")
- Dim matchs As Object, match As Object
- Dim x As String
-
- Set objwinhttp = CreateObject("WinHttp.WinHttpRequest.5.1")
- Set objxmlhttp = CreateObject("Msxml2.ServerXMLHTTP.6.0")
-
- mname = ActiveWorkbook.Name
- UserName = Sheets("main").Cells(2, 2)
- pass = Sheets("main").Cells(3, 2)
- bname = Sheets("main").Cells(5, 2)
- ds = Sheets("main").Cells(9, 2)
- accept = "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
- useragent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Tablet PC 2.0)"
- contype = "application/x-www-form-urlencoded"
- alive = "Keep -Alive"
- leg = 24
- URL = "http://xxx.xxx.xxx.xxx:9009"
- referer = "http://xxx.xxx.xxx.xxx:9009/login.jsp"
- Call firstgetData(objwinhttp, URL)
-
- If objstatus <> "200" Then
- End
- End If
-
- URL = "http://xxx.xxx.xxx.xxx:9009/auth.jsp"
- referer = "http://xxx.xxx.xxx.xxx:9009/login.jsp"
-
- data = "login=" & UserName & "&passwd=" & pass
- leg = Len(data)
- Call postData(objwinhttp, URL)
-
- If objstatus <> "302" Then
- End
- End If
- URL = "http://xxx.xxx.xxx.xxx:9009/new_left.jsp?topid=40"
- referer = "http://xxx.xxx.xxx.xxx:9009/new_top.jsp"
- leg = 0
-
- Call getData(objwinhttp, URL)
- If objstatus <> "200" Then
- End
- End If
-
- newusername = Sheets("edit").Cells(2, 2)
- URL = "http://xxx.xxx.xxx.xxx:9009/4/query_user_info_computer_e.jsp?userid=&loginname=" & newusername & "bindingphone=&usertype=&username=&branch=&state=&isbinding=&realport=&atu_c=&vp=&vc=&switch=&su=&ip=&equipsource=&discnt=&ratiotype=&displaycon=userid%7Eusername%7Estate%7Ebranch%7Eisbinding%7Eatu_c%7Eusertype%7Esplitter%7Eswitch%7Edslamip%7Edslamid%7E"
-
- referer = "http://xxx.xxx.xxx.xxx:9009/4/query_user_info_computer_e_toolbar.jsp"
-
- Call getDataxml(objxmlhttp, URL)
-
- Sheets("temp").Cells(1, 1) = getrptext
- 以下省略
- Private Sub firstgetData(objwinhttp As Object, URL As String)
- With objwinhttp
- .Option(6) = False '不重定向
- .Open "get", URL, False '获取第一个动态的POST参数,一般是用GET提交得到,这一点通过抓包软件可以确认
- .setRequestHeader "Connection", "Keep-Alive"
- .send
- .WaitForResponse
- getrptext = .responseText
- Cookie = .getResponseHeader("Set-Cookie")
- Cookie = Split(Cookie, ";")(0)
-
- objstatus = .Status
-
-
-
- End With
-
- End Sub
- Private Sub getData(objwinhttp As Object, URL As String)
- With objwinhttp
- .Option(6) = False '不重定向
- .Open "get", URL, False '获取第一个动态的POST参数,一般是用GET提交得到,这一点通过抓包软件可以确认
-
- .setRequestHeader "Accept", accept
- If referer <> "" Then
- .setRequestHeader "Referer", referer
- End If
- .setRequestHeader "User-Agent", useragent
- .setRequestHeader "Content-Type", contype
- .setRequestHeader "Connection", alive
- If leg <> 0 Then
- .setRequestHeader "Content-Length", leg
- End If
- '.setRequestHeader "Cookie", Cookie
- .send
- .WaitForResponse
- getrptext = .responseText
- objstatus = .Status
-
- End With
-
- End Sub
- Private Sub getDatays(objwinhttp As Object, URL As String)
- With objwinhttp
- .Option(6) = False
- '.Option(WinHttpRequestOption_EnableHttp1_1) = False
- .Open "GET", URL, False '获取第一个动态的POST参数,一般是用GET提交得到,这一点通过抓包软件可以确认"
- .setRequestHeader "Accept", "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
- .setRequestHeader "Referer", "http://123.81.251.164:7001/4/query_user_info_computer_e_toolbar.jsp"
- .setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 1.1.4322)"
- '.setRequestHeader "Accept-Encoding", "gzip, deflate"
- .setRequestHeader "Connection", "close"
- .setRequestHeader "Cookie", Cookie
- .setRequestHeader "Host", "123.81.251.164:7001"
- .send
- .WaitForResponse
- getrptext = .responseText
-
-
- objstatus = .Status
-
- End With
-
- End Sub
- Private Sub getDataxml(objxmlhttp As Object, URL As String)
- With objxmlhttp
- '.Option(6) = False
-
- .Open "GET", URL, False '获取第一个动态的POST参数,一般是用GET提交得到,这一点通过抓包软件可以确认"
- .setRequestHeader "Accept", "image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
- .setRequestHeader "Referer", "http://123.81.251.164:7001/4/query_user_info_computer_e_toolbar.jsp"
- .setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 1.1.4322)"
- .setRequestHeader "Accept-Encoding", "gzip, deflate"
- .setRequestHeader "Connection", "Keep-Alive"
- .setRequestHeader "Cookie", Cookie
- '.setRequestHeader "Hose", "123.81.251.164:7001"
- .send
- '.WaitForResponse
- MsgBox .readyState
-
-
-
-
- If .readyState = 3 Then
- getrptext = .responseBody
- End If
-
- Debug.Print getrpbody
- objstatus = .Status
-
- End With
-
- End Sub
- Private Sub postData(objwinhttp As Object, URL As String)
- With objwinhttp
- .Option(6) = False '不重定向
- .Open "post", URL, False '获取第一个动态的POST参数,一般是用GET提交得到,这一点通过抓包软件可以确认
-
- .setRequestHeader "Accept", accept
- If referer <> "" Then
- .setRequestHeader "Referer", referer
- End If
- .setRequestHeader "User-Agent", useragent
- .setRequestHeader "Content-Type", contype
- .setRequestHeader "Connection", alive
- If leg <> 0 Then
- .setRequestHeader "Content-Length", leg
- End If
- '.setRequestHeader "Cookie", Cookie
- .send (data)
- .WaitForResponse
- getrptext = .responseText
-
- objstatus = .Status
-
-
- End With
-
- End Sub
复制代码 |
|