Get selected elements in Safari

Any ideas on how to pick elements on websites for further processing? Links and images in particular.

Can you for example make a text selection, and then find all the href attributes inside it? Could you use do javascript to get element(s) of a certain type that are under the cursor?