Copy URLs from document

Greetings, I’m sorry to bother but I’ve looked all over and tried to figure it out for myself but can’t seem to get it.

I’m trying to create a Shortcut that searches a document for URLs, copies those URLs, then sends the links to a clipboard manager such as Yoink. I am usually working in a Google Doc and I don’t mind whether I have to do this while using the Google Docs app or have the document open in a Safari tab.

Is this possible? I really appreciate any help.

1 Like

I’ve have tried and tried. Shortcuts can’t even go through a PDF and pull out the URL’s. Shortcuts can’t go through any document, search the text, find the URL’s and copy them to the clipboard. I guess this is impossible.

1 Like

I would guess that you could probably do this via a Run JavaScript on a web page action and parsing the document object for URLs, then excluding all of the links outside of the body of the Google document. It would be far from trivial to do, but I think it should technically be viable.

1 Like

Double check that you PDF includes a text layer. It should be able to get URLs from the text if the URLS are defined as text.

If they are hyperlinks, then you would need to convert the PDF to a format supported by the Get URLs from Input action.

1 Like

If the URLs are written out fully in the document, you could try OCRing the PDF and pulling the URLs from that. Here’s a shortcut I use for getting URLs from a screenshot:

https://www.icloud.com/shortcuts/8756ae51d2954bae8bba0672ef5d5a00

This one gets the last screenshot taken, uses Toolbox Pro to pull out the text, gets URLs from the text, and lets you pick from them. Maybe you can use part of it? You could make images from the PDF, OCR them in Toolbox Pro, and pull URLs from that.

1 Like