Re: Extracting data from HTML
Re: Extracting data from HTML
- Subject: Re: Extracting data from HTML
- From: Irwin Poche <email@hidden>
- Date: Tue, 10 Feb 2004 05:00:16 -0600
If you just paste the URL into Safari, the resulting page will include
a statement like "Total Est. Distance: 12.3 miles." Are you saying
curl returns this information ? I cannot imagine why I do not get
that.
On Feb 10, 2004, at 1:09 AM, BJ Terry wrote:
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.
_______________________________________________
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.