|
Private Sub getPostData(objWinhttp As Object, URL As String)
Dim tt$
'第一次调用取得post的几个参数
Application.StatusBar = "正在获取Post参数..."
With objWinhttp
.Option(6) = 0 '不重定向
.Open "GET", URL, False '获取第一个动态的POST参数,一般是用GET提交得到,这一点通过抓包软件可以确认
.setRequestHeader "Connection", "Keep-Alive"
.send
tt = .responseText
With CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") '调试用,得到网页源代码数据,放入剪贴板
.SetText tt
.PutInClipboard
End With
End With
If CheckServerError(objWinhttp.Status, tt) Then '判断是否网页返回错误
Application.StatusBar = False
Application.ScreenUpdating = True
Set objWinhttp = Nothing
Set dicMapIndex = Nothing
End
End If
'如果网页正确,下面的代码从网页源代码中取出post提交的动态参数
viewstate = Split(Split(tt, "__VIEWSTATE"" value=""")(1), """")(0) '取得VIEWSTATE的Post参数
eventvalidation = Split(Split(tt, "__EVENTVALIDATION"" value=""")(1), """")(0) '取得EVENTVALIDATION的Post参数
txtDay = Split(Split(tt, "ctl00$cph_content$txtDay"" type=""text"" value=""")(1), """")(0) '提交日期,默认当日
End Sub
Sub kl()
Set objWinhttp = CreateObject("Microsoft.XMLHTTP")
URL = "http://www.gzgcjg.com/gzqypjtx/Estimate/ZY/MainQueryMarkZY.aspx?"
getPostData objWinhttp, URL
End Sub
请问我的代码有啥错,运行不了哈
谢谢
|
|