|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub t()
- Dim objWinHttp, Url$, Str$, m%, n%, i%, j%
- Dim arr
- Url = "http://www.gzgczj.com:8080/costRegulatory/project.do"
- Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
- With objWinHttp
- '第一次post
- .Open "POST", Url, False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .setRequestHeader "Cookie", "JSESSIONID=2DC7701F8631495E370469482999EFE6"
- .setRequestHeader "Referer", "http://www.gzgczj.com:8080/costRegulatory/user.do?method=changeIndex&fareaId=1"
- .send "method=showProjectList&frecordProstatus=1010&isVisitor=1&fprojAreaId=-1&fprojName=&page.pageNO=1"
- m = Split(Split(.responseText, "共")(1), "页")(0) '得到总页数
- '以取2页为例
- For i = 1 To 2 'm
- .Open "POST", Url, False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .setRequestHeader "Cookie", "JSESSIONID=2DC7701F8631495E370469482999EFE6"
- .setRequestHeader "Referer", "http://www.gzgczj.com:8080/costRegulatory/user.do?method=changeIndex&fareaId=1"
- .send "method=showProjectList&frecordProstatus=1010&isVisitor=1&fprojAreaId=-1&fprojName=&page.pageNO=" & i
- Str = VBA.Replace(.responseText, vbCrLf, "")
- arr = Split(Str, "<TD class=""c_td"" width=""65%"">")
- Cells.ClearComments '清除工作表内原数据
- For j = 1 To UBound(arr)
- n = n + 1
- Cells(n, 1) = n
- Cells(n, 2) = Split(arr(j), "</TD>")(0) '工程名称
- '其他数据省略
- Next j
- Next
- End With
- End Sub
复制代码 |
|