Parsing comments from HTML...
Parsing comments from HTML...
- Subject: Parsing comments from HTML...
- From: Peter Bunn <email@hidden>
- Date: Fri, 1 Nov 2002 10:28:07 -0600
Hello:
I'm writing a script that tries to retrieve text which has been commented
out in HTML. (The comment text is automatically generated by another
script so the formatting is controllable/predictable.) Below is a script
snippet adapted from an AS Guidebook example. Using two 'unique'
characters (common as shown here; non-ASCII in the actual script), the
script does, in effect, read and return the items listed between the
symbols... but as the amount of HTML grows, everything slows to a crawl
(roughly 2 minutes to retrieve 100 items from an HTML page of 100K).
I've tried other methods - involving 'read to the offset of' and tid's,
but haven't had much luck... mostly just shots in the dark, owing to my
inexperience.
I wonder if there's a way to speed up the process?
As an added bonus, if there's a way to sort the final list
alphabetically, that would be of great interest also.
Any/all suggestions are most welcome.
Thanks.
Peter B.
OS 8.6 / AS 1.3.7
(I've left the HTML comment symbols out in case the list server wouldn't
handle them properly...)
-----
set the_read to "
*Cow
Chicken
Pig
$
*Duck
Goose
$"
set _copy_ to false
set the the_list to ""
repeat with this_character in the_read
set this_character to the contents of this_character
if this_character is "*" then
set _copy_ to true
else if this_character is "$" then
set _copy_ to false
else if _copy_ is true then
set the_list to the_list & this_character
end if
end repeat
set _Priors_ to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set the_reindex_list to (every text item of the_list) as list
set AppleScript's text item delimiters to _Priors_
set the_reindex_list to text items 1 through -2 of the_reindex_list as
list
-->{"Cow", "Chicken", "Pig", "Duck", "Goose"}
---------------------------------------------
_______________________________________________
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.