Hi,
I am trying to make a destination origin matrix, one with distance and one with time, for a linear programming model which needs to have every possible distance and time for a combination of a hundred or so locations. I have downloaded Selenium and my plan is to use google maps to get all of the data, and then I will loop through my locations list to collect all of the data I need. I am having trouble with a few lines of code, basically just pulling the distance and time information from the google maps webpage and putting it into a string. Anyway, any help with the code would be appreciated. The specific line that won't work is the one that assigns the text associated with the xpath to the string.
Sub Destination_Origin_Matrix()
Dim driver As New WebDriver
Dim str As String
Dim origin As String
Dim destination As String
driver.Start "chrome", "http://www.google.com/" 'Launch the browser
driver.Open "https://www.google.com/maps?m&ll=37.6,-95.665&z=4&output=classic&dg=ntvo" 'Open to google maps
driver.Click "id=d_launch" 'Click on directions button
driver.Type "id=d_d", origin 'Type the text present in the string origin
driver.Type "id=d_daddr", destination 'Type the text present in the string destination
driver.Click "id=d_launch" 'Click on directions button again to get out of textbox
driver.Click "id=d_sub" 'Click on the "Get Directions" button to get directions
str = driver.findElementsByXPath("//div[@class='altroute-rcol altroute-info']/span[1]").Text 'should put distance info into str string
driver.stop 'Stop the browser
End Sub
Bookmarks