• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Extracting data from HTML
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extracting data from HTML


  • Subject: Re: Extracting data from HTML
  • From: Michael Terry <email@hidden>
  • Date: Tue, 10 Feb 2004 03:07:21 -0800

On Feb 9, 2004, at 8:13 PM, Irwin Poche wrote:

If you run this script and then paste the URL into Safari, I think
you'll see what I mean.

tell application "Finder"
set theURL to
"http://www.mapquest.com/directions/main.adp?
1a=13701 Independence Parkway&1c=Fort Worth&1s=TX&src=maps&2s=TX& 2
c=Dallas"
set curlCmd to "curl \"" & theURL & "\""
set thePage to (do shell script curlCmd) as text
display dialog (length of thePage)

set cityMarkStart to "<td valign=center align=left class=size12>"
set DistanceMarkStart to "Total Est. Distance:"

display dialog (offset of cityMarkStart in thePage) -- always zero
display dialog (offset of DistanceMarkStart in thePage) -- always zero

thePage

end tell


Assuming you had already scripted Safari to load the driving directions, you could do something like this:

---------------------------

tell application "Safari" to tell front document
tell its text
set addyRef to a reference to paragraph before paragraph before (first paragraph whose word -1 is "Maneuvers")
set destAddy to get characters 2 thru -25 of addyRef
set distance to get (characters 1 thru -2 of (first paragraph whose word 1 is "Total"))
end tell
end tell
set text item delimiters to ""
display dialog destAddy as string
display dialog distance as string

---------------------------

which I partly did just to see if it were possible. Scripting text in Safari was less fun that dragging a cactus across my face. Maybe I just don't have enough experience scripting application text objects.


Mike
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Extracting data from HTML (From: Irwin Poche <email@hidden>)

  • Prev by Date: Re: Extracting data from HTML
  • Next by Date: Re: Make Alias
  • Previous by thread: Re: Extracting data from HTML
  • Next by thread: Something to watch out for...
  • Index(es):
    • Date
    • Thread