Extract hyperlinks from Rich Text Clipboard content or select text on Mac

I would like to get a list of all the hyperlinks in any formatted text that I select on a Mac (formatted text such as a web page or word processor document).

It is advisable that I use Applescript or Automator to extract this list of hyperlinks from text (so that I can then use Applescript to further process these URLs).

Note that I'm talking about hyperlinks being retrieved from formatted text, and not just retrieving URLs from text containing plaintext URLs.

This extracting a hyperlink from formatted text looks like it should be a simple programming task, but I'm struggling to find a way to do this in Applescript or Automator.

Automator can be configured to accept extended text input from text selection, or it can type rich text from the clipboard, but I cannot find a way to access this rich text as a string in Automator or Applescript, so then I can extract the URL hyperlinks from the string rich text data.

Once I get access to rich text data as a string, there will be no problem retrieving the urls.

Any suggestions on how I can solve this problem would be greatly appreciated.

+4
1

Applescript , . make shell script 'textutil', :

perl -ne 'print chr foreach unpack("C*",pack("H*",substr($_,11,-3)))' | 
textutil -stdin -stdout -convert html -format rtf

URL-. Automator " " . Automator, Applescript. , , . , , : Workflow example

, . .

: , Automator RTF.

keystroke "c" using command down

, . . : Workflow Example

+3

Source: https://habr.com/ru/post/1607940/


All Articles