It is not easy to scrape a web site.
Test a couple of locations
Look at the URL created
Look at the page created (page source)
It is using a lot of Google functions. It may be better to get the Google API and supply what is needed to get back what is desired.
Assuming you already have geographical coordinates in your filemaker system, the URL format is:
So in filemaker, your script would look something like this to get the time that is displayed as blue bold text on that site:
Set Variable [ $fromlong ; yourAddresses::OriginationLongitude ]
Set Variable [ $tolat ; yourAddresses::DestinationLatitude ]
Set Variable [ $tolong ; yourAddresses::DestinationLongitude ]
Set Variable [ $url ; "http://www.travelmath.com/driving-time/" & $fromlat & "," & $fromlong & "/to/" & $tolat & "," & $tolong ]
Insert From URL [ $url ; yourAddresses::GlobalTextField ]
Set Variable [ $time ;
str = yourAddresses::GlobalTextField;
p1 = Position( str ; "id=\"drivetime\"" ; 1 ; 1 );
start = p1 + 14; //SEE NOTE
end = Position(str ; "<" ; start ; 1 )
Middle ( str ; start ; end )
Show Custom Dialog [ "Your Time:" ; "Your travel time is estimated to be: " & $time ]
A few notes on the above:
1) This is assuming you already have latitude and longitude stored for your source and destination addresses. If not, search this forum, it's a topic that has been covered a number of times before.
2) You don't really need all the set variables steps at the beginning, you can calculate the entire URL inside of the Insert From URL script step, I just "exploded" it a bit so you can see it spread out.
3) The last Let() function essentially is "scraping" the web content to get the string of text that is between the tags in that website HTML, the full line in question in the source code looks like this:
<h3 class="space" id="drivetime">2 hours, 18 minutes</h3>
So essentially I am trying to calculate what to grab using the Middle() function between the > after "drivetime" and the < before /h3. This may need slight adjustment as I'm not sure the +14 is correct.
4) This requires being connected to the internet to work of course, so offline iOS files without an internet connection may result in errors.
5) There is no error checking in the above. You should add it as needed for your solution.
6) The site itself parses time into a display friendly format, so it's not that great for getting a value to store, like just a number of minutes.