|
本帖最后由 onlycxb 于 2015-1-12 09:51 编辑
- Option Explicit
- Sub ChinaAirlines_CARGO()
- Dim Xml As New MSXML2.XMLHTTP, html As New HTMLDocument
- Dim URL As String, tb, tr, td, i As Integer, j As Integer, k, m, VIEWSTATE As String
- URL = "http://cargo.china-airlines.com/CCNet/pgFreightStatus/cgoTrack.aspx?AWBPrefix=297&AWBNumber=26846503"
- With Xml
- .Open "GET", URL, False: .send
- html.body.innerHTML = .responseText
- VIEWSTATE = encodeURI(html.getElementById("__VIEWSTATE").Value)
- .Open "POST", URL, False
- .setRequestHeader "content-type", "application/x-www-form-urlencoded; charset=UTF-8"
- .send "ScriptManager1=ScriptManager1%7CbtnQuery&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=" & VIEWSTATE & "&hdn_menu_head_index=&p=SEARCH&o=4&v=root&r=2¤tCalForm=dep¤tdate=115-01-11&onload=&CCNetInfo1%24txtCurrentDate=&txtAWBPrefix=297&txtAWBNumber=26846503&__ASYNCPOST=true&btnQuery.x=0&btnQuery.y=0"
- ' Debug.Print InStr(.responseText, "AE0992") '找到数据了
- html.body.innerHTML = .responseText
- Dim n '表格起始行
- Cells.Clear
- Set tb = html.all.tags("div")
- For i = 0 To tb.Length - 1
- If tb(i).className = "menu_body" Then '
- For j = 0 To tb(i).ChildNodes.Length - 1
- Set tr = tb(i).ChildNodes(j).all.tags("tr")
- For k = 0 To tr.Length - 1
- n = n + 1
- For m = 0 To tr(k).ChildNodes.Length - 1
- Cells(n, m + 1) = tr(k).ChildNodes(m).innerText
- Next m
- Next k
- Next j
- End If
- Next i
- End With
- End Sub
- Function encodeURI(strTobecoded As String) As String
- With CreateObject("msscriptcontrol.scriptcontrol")
- .Language = "JavaScript"
- encodeURI = .Eval("encodeURIComponent('" & strTobecoded & "');")
- End With
- End Function
复制代码
工作簿1.rar
(18.71 KB, 下载次数: 8)
|
评分
-
2
查看全部评分
-
|