applescript to copy text which extends off page

I’m trying to use applescript to copy the text which lies between two known UI elements in a Safari window. Using cliclick and Applescript Toolbox I can see how to select the relevant text if the two critical UI elements are both visible in the window (because their screen co-ordinates can be found). But what if one of the UI elements lies outside the screen? Is there a way of selecting the text for copying under those circumstances?

If you know the UI elements, I’d forget about UI scripting with clickclick and just get the page source and locate the HTML for the known UI elements and grab the text between them.


tell application "Safari" to set pageHTML to source of the front document

That text may contain additional HTML or CSS formatting elements that need to be removed… or maybe you need to render those elements and copy the resulting rich text? I still think it would be easier and more reliable to deal with those issues than to UI script it.

If you can point us to an example webpage and let us know what the UI delimiters are, we might be able to be more helpful.