VB6如何判断webbrowser中的谷歌地图加载完毕
url="https://maps.google.com/maps?saddr=8850+Concord+Dr.+Fredonia+NY&daddr=6805+Fox+Run+Crystal+Lake+IL"
WebBrowser1.Navigate URL, False
Private Sub Command1_Click()
URL = "https://maps.google.com/maps?saddr=8850+Concord+Dr.+Fredonia+NY&daddr=6805+Fox+Run+Crystal+Lake+IL"
WebBrowser1.Navigate URL, False
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
Debug.Print WebBrowser1.Document.All.tags("span")(67).innerText & "---" & WebBrowser1.Document.All.tags("span")(68).innerText
End Sub
import win.ui;
/*DSG{{*/
var winform = win.form( bottom=637;right=1183;text="正在打开谷歌地图......" )
/*}}*/
import web.form;
var wb = web.form( winform,,,,true);
winform.show();
wb.go("https://maps.google.com/maps?saddr=8850+Concord+Dr.+Fredonia+NY&daddr=6805+Fox+Run+Crystal+Lake+IL")
wb.wait(); //等待地图打开
var ele = wb.getEle("altroute_1") //取第二条建议线路
ele.click();//选择第二条线路
//启动消息循环
win.loopMessage();
Sub 北京_上海线路_谷歌查询()
Cells.Clear
Set oDoc = CreateObject("htmlfile")
Set ms = CreateObject("MSScriptControl.ScriptControl")
ms.Language = "JScript"
出发地 = ms.Eval("encodeURIComponent('中国北京市');")
目的地 = ms.Eval("encodeURIComponent('中国上海市');")
URL = "https://maps.google.com/maps?f=d&source=s_d&saddr=" & 出发地 & "&daddr=" & 目的地 & "&output=js&hl=zh-CN&geocode=&aq=0&vps=1&vpsrc=0&mra=ls"
With CreateObject("Msxml2.XMLHTTP")
.Open "GET", URL, False
.send
str1 = "a=" & Split(Split(.responsetext, ",""state"");}")(0), "function onLoad(){w.loadVPage(")(1)
End With
ms.AddCode str1
str2 = ms.Eval("a.panel")
oDoc.body.innerHTML = str2
Set r = oDoc.all.tags("li")
For i = 0 To r.Length - 1
Debug.Print Replace(r(i).innerText, vbCrLf, ",") '三条线路
Next i
Set r = oDoc.all.tags("table")(2).Rows
For i = 0 To r.Length - 1 Step 2
Cells((i + 2) / 2, 1) = r(i).Cells(1).innerText
Cells((i + 2) / 2, 2) = r(i + 1).Cells(2).innerText
Next i
URL = "https://maps.google.com/maps?mra=ai&via=1&saddr=" & 出发地 & "&daddr=32.4133964936869,119.63299054652452+to:" & 目的地 & "&output=dragdir&jsv=466g&sll=35.568417,118.940072&sspn=8.60896,52.954102&vpsrc=0&geocode=FR7jYAId5jzwBim5LBTnllLwNTGKqQ-vIFZiuQ%3BFdSW7gEdXnQhBykxJMnzu5G2NTFllYfnMRjuYg%3BFbmJ3AEdqIo9BykzPPWxQHCyNTGhZMMjlBKVAg"
With CreateObject("Msxml2.XMLHTTP")
.Open "GET", URL, False
.send
str1 = "a=" & .responsetext
End With
ms.AddCode str1
str2 = ms.Eval("a.alt[0].html")
oDoc.body.innerHTML = str2
Set r = oDoc.all.tags("table")(0).Rows
For i = 0 To r.Length - 1 Step 2
Cells((i + 2) / 2, 3) = r(i).Cells(1).innerText
Cells((i + 2) / 2, 4) = r(i + 1).Cells(2).innerText
Next i
URL = "https://maps.google.com/maps?mra=ai&via=1&saddr=" & 出发地 & "&daddr=34.78873657097836,117.29354236274957+to:" & 目的地 & "&output=dragdir&jsv=466g&sll=38.548165,118.916016&sspn=9.207238,105.908203&vpsrc=0&geocode=FR7jYAId5jzwBim5LBTnllLwNTGKqQ-vIFZiuQ%3BFYDVEgId5sH9Binv2JQYH4fGNTEcY6pn4AjPJg%3BFbmJ3AEdqIo9BykzPPWxQHCyNTGhZMMjlBKVAg"
With CreateObject("Msxml2.XMLHTTP")
.Open "GET", URL, False
.send
str1 = "a=" & .responsetext
End With
ms.AddCode str1
str2 = ms.Eval("a.alt[0].html")
oDoc.body.innerHTML = str2
Set r = oDoc.all.tags("table")(0).Rows
For i = 0 To r.Length - 1 Step 2
Cells((i + 2) / 2, 5) = r(i).Cells(1).innerText
Cells((i + 2) / 2, 6) = r(i + 1).Cells(2).innerText
Next i
End Sub