the point of it is to grab some information from the text displayed on the page. This usually works… the problem is with the delay. Sometimes the browser takes a while to load the page, and if it takes longer than the delay time I’ll get an error saying that pageBody is not defined (ie, it tried to grab text which didn’t exist yet). Is there some way to tell when a page has finished loading? I was thinking something using the “do JavaScript” command, but I don’t know what. Any ideas?
Of course, the best solution is to not use Safari at all.
Since you state “the point of it is to grab some information from the text displayed on the page” and therefore you don’t care about the display you can do the same thing via a shell script:
set pageSource to do shell script "curl [url=http://www.somewebpage.com/subfile/something.html]http://www.somewebpage.com/subfile/something.html"[/url]
Now you have the page source and you can parse it to find the data you’re after. It also happens much faster since you don’t have to wait for the embedded images, etc. to load, nor for the page to render.
Ah! Thank you both. That JavaScript command was just what I was looking for, and the “do shell script” command is even more usefull. (I hope I didn’t cause too much annoyance if this has been posted many times before). Thanks again!