Getting Distance out of Google Map (Safari)

Hi scripters,

I’m working with FileMaker Pro and AS.

Now, for a driver’s logbook (our fiscal authorities love that!), I want to combine FileMaker and Safari via AppleScript.
I was already successful in getting the exact map with distance between my home and the travel destination. It also shows on the left side the exact distance.
But: How can I get any text out of Safari in order to extract this shown distance and put it into the appropriate field within my database. It’s not absolutely necessary for you to tell me the final result. Just some hints how to suck text out of Safari would be appreciated!
Thanks in advance,

Andreas

Hi Andreas,

does this work?

tell application "Safari" to set a to text of document 1
set {TID, text item delimiters} to {text item delimiters, "Travel" & (ASCII character 10)}
set a to text item 2 of a
set text item delimiters to " “ "
set a to text item 1 of a
set text item delimiters to TID
display dialog a

Grüße nach Bayern

Hi Stefan,

you’re a wizzard, almost…

First I’ve got an error window (a real large one) when running your script.
Then I replaced “text item 2” with with “text item 1” in line 3 and the result was excellent! (Still wondering why, by the way…)
I just had to pick the last paragraph of this result and received exactly the driven kilometers! Superb!
Now I am able to loop thru my database and get all the distances automatically. (My shoulder is looking forward to the friendly clap of my tax collector). Hmmm… but why does it work this way?

However, merci vielmals nach St. Gallen (one week ago I passed by). Helps me a lot (although I’m still wondering how…)!

Andreas

P.S. Somehow the Swiss are great (Apple)Scripters. How does it come?

probably a custom window looks different than the Munich to Ulm sample.
I just took this to write the script

Sorry, I live in Switzerland but I am german (Schwabeländle) :slight_smile:
But I think there are many great native swiss scripters :wink:

Text item 2 works for me Stefan. Neat little script.

In my long experience, Swiss and Germans are very methodical by nature – Scripting requires attention to methods. What amazes me is that so many scripters are musicians and so few are scientists or engineers. Scripting must involve a creative stroke that musicians have.

Hi Stefan, hi Adam,

tried it again with “text item 2” and got the same error message.

Here’s what works with me:

tell application “Safari” to set a to text of document 1
set {TID, text item delimiters} to {text item delimiters, “Travel” & (ASCII character 10)}
set a to text item 1 of a
set text item delimiters to " “ "
set a to text item 1 of a
set b to last paragraph of a
set text item delimiters to TID
get b

As a result I get the distance in “b”. (…what makes me smile)

Perhaps I am not really up-to-date with my browser and OSX?

Glad that there is at least one German scripting-genius! (Well, we all know that Swabians can do everything, except…) And in Canada, I guess, there is a whole bunch of them, isn’t it?

Thanks again, you’ve made my day!

Andreas