• 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: BJ Terry <email@hidden>
  • Date: Mon, 9 Feb 2004 23:09:38 -0800

On my computer, Safari and curl give identical results.* Neither of them have the search term in your strings. I presume that the page uses cookies or something, which wouldn't work correctly in curl (unless you knew what they were and specified that they be sent). In this case using Safari is indeed the simpler choice.

BJ

*Well, not technically identical, I ran a diff on the two files, and they differed on some lines, which appeared to have randomly generated tokens in them.

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

On Feb 9, 2004, at 2:47 PM, Doug McNutt wrote:

At 13:37 -0600 2/9/04, Irwin Poche wrote:
Quite sometime ago I scripted IE to load a page ever so often, pull
some information from the page, and write out a summary of that
information.

Take the time to learn curl and perl. Curl will download the page and
perl with its regular expression capability is great for extracting
repeated information. The whole thing can be scripted and run with
cron. A simple AppleScript can initiate the whole thing in Mac OS neXt
but it will also run on a $20 Linux box without modification.

Ask off line for some samples which are quite simple so long as you
don't get involved with https and certification of public keys.

--

Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.



Thanks Doug - I was unaware of curl. Very handy. I am aware of Perl
and I'm learning it, slowly, so at this point I'll still use AS.

Unfortunately curl and Safari's View Source give me different results.
curl does not give me the information I'm looking for.

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
_______________________________________________
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.
_______________________________________________
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.

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

  • Prev by Date: Re: Scripting Additions Calls in Tell Blocks
  • Next by Date: Re: Sed replace oneline nogo in Applescript
  • Previous by thread: Re: Extracting data from HTML
  • Next by thread: Re: Extracting data from HTML
  • Index(es):
    • Date
    • Thread