|
请参考
Sub YZC51()
Dim s As String, URL, Udate, Fromto, Eendto, Arr(0 To 500, 1 To 16)
r = Cells(Rows.Count, 1).End(xlUp).Row + 2
Range("a5:P" & r) = ""
Application.ScreenUpdating = 0 '关闭屏幕显示
Udate = Format([G2], "yyyy-mm-dd")
Fromto = Application.VLookup([B2], [TODM], 5, 0): Eendto = Application.VLookup([D2], [TODM], 5, 0)
URL = "https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date=" & Udate
URL = URL & "&leftTicketDTO.from_station=" & Fromto
URL = URL & "&leftTicketDTO.to_station=" & Eendto
URL = URL & "&purpose_codes=ADULT"
With CreateObject("MSXML2.XMLHTTP")
' With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", URL, False
.setRequestHeader "Accept-Encoding", " gzip, deflate, sdch, br" '下面这些是客户端证书
' .setRequestHeader "Connection", "Keep-Alive"
' .setRequestHeader "Accept-Language", "zh-CN,zh;q=0.8"
' .setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"
.send
s = .responsetext
End With
s = Split(Split(s, "[")(1), "]")(0) & ","
s = Replace(s, "||", "|-|")
s = Replace(s, "-||", "-|-|")
n = 5
V = Split(s, """,")
RW = UBound(V)
详情请见附件 |
|