Thx again for your advice,
1) I don't think, however, that the page not being fully loaded is the problem. I had been using a following function to load the url. It's practically the same as yours. (I put the delay time in a variable, because some sites I use take longer to reply on different days, so I can adjust it accordingly at the head of applescript code.
on LoadURL(theURL, DelayTimeLong)
tell application "Safari"
set URL of document 1 to theURL
delay DelayTimeLong
repeat
----use Safari's 'do JavaScript' to check a page's status
if (do JavaScript "document.readyState" in document 1) is "complete" then exit repeat
delay 1
end repeat
end tell
end LoadURL
ad 2) I've been using a similar sollution, where I would use applescript to store the processed entries in its cashe by calling:
set ProcessedCashe to ProcessedCashe & CharacterEntry --ensures that the entry won't be duplicated
and checking the uniquness of each new search result by using:
on CheckIfUnique(CharacterEntry, ProcessedCashe)
set UniquenessValue to "unique"
repeat with p from 1 to count of ProcessedCashe
--display dialog CharacterEntry & return & "vs." & return & item p of ProcessedCashe
if item p of ProcessedCashe is CharacterEntry then
set UniquenessValue to "duplicate"
exit repeat
end if
end repeat
return UniquenessValue
end CheckIfUnique
but as you see, it was yet again another loop. I remember I wanted just to bypass the loop and use something along the lines of:
if ProcessedCashe contains CharacterEntry then
-- skip
else
--proceed
end if
but for one reason or another couldn't get it to work. I'll give your sollution a try soon. I think it might be more efficient. At the moment, I'm using a delay 0.3 after each skipped item, which prevents my fans from spinning out of controll, although I've noticed that the average speed per character is much lower.
Comparing your sollution to mine, I'm starting to suspect the problem is cummulative throughout the entire code, not just one function. I'm new to AppleScript, and though I can get it to do what I want (having picked the brains of people like you, I might add), I probably don't get it to do these things in the most efficient way.
I'll have to try to improve with with time.