Get Web URL, Publication, Article Title, Author, and Selected Text From a Web Page

I am looking to make a custom link post shortcut to use when on a web page in Safari. I want it to get the URL, Publication, Article Title, Author, and Selected Text to then format it in a specific way. I basically want to take these pieces of information and format it as a blog post in a markdown app (Ulysses, IA Writer, Byword, etc.). I want it to be formatted as follows:

# ARTICLE TITLE

AUTHOR writing for [PUBLICATION](URL):

> SELECTED TEXT

If there are instances where KM doesn't offer this kind of thing (like an Author) I am happy to input it manually when I run the action. Something like it having a text prompt where I just input the Author name and is saves it when outputting the formatted text.

If someone can help me out with this I would greatly appreciate it.

I have a macro/script that will do most of that (depending on the web site).
However, what is the source for "Publication"?

It would be best if you can provide a real-world example of a web page (post the URL). I can then develop/test against it.

Sure. If you go to https://www.macstories.net/reviews/soulver-3-for-mac-the-macstories-review/ and select the first paragraph I want it to have this spit out:

    # Soulver 3 for Mac: The MacStories Review – MacStories

[John Voorhees writing for MacStories](https://www.macstories.net/reviews/soulver-3-for-mac-the-macstories-review/):

The strength of Soulver lies in its flexibility. Full-fledged spreadsheet apps like Numbers and Excel have their place. However, day-to-day life requires calculations that don't demand that level of horsepower and benefit from contextualizing numbers with text. It’s the kind of math that happens in notebooks and on the back of envelopes. By combining elements of a text editor, spreadsheet, and plain English syntax, Soulver commits those easily-lost notebook scribblings to a format that allows for greater experimentation and easier sharing.

1 Like

Thanks for the URL and example. But I still need to know the criteria, in general, that you want to use to identify the "Publication".

In your example, it could be the SLD:
serverName.SLD.TLD

where

  • SLD is second level domain
  • TLD is top level domain

So with a base URL of "https://www.macstories.net"

  • SLD = "macstories"
  • TLD = "net"

I did NOT see anything in the web page metadata labeled "Publication".

The only data in the page header that had an attribute exactly = "MacStories" was this one:

<link rel="alternate" type="application/rss+xml" title="MacStories" href="https://www.macstories.net/feed/">

So, if this element exists on all of the pages that you want to get this info for, we could use that. One approach is try to get that element, and if it does not exist, the fall back to the SLD.

So, let us know what will work for you.

Honestly I can just input the publication manually via user input if that’s easier. From there it can just be a variable called “publication” and be put into the final text output.

If it’s easier for you SLD is fine.

Howdy -- a year later and I'm :mag: searching for exactly this tool -- Safari to ia Writer. Can you share what you got?

Yes, I am also looking for a similar thing - please can you share the macro that was created for this requirement. Many thanks.

Why not run a Chrome / Safari extension? They may be JavaScript which runs fast in browser.
If an AppleScript aimed to control the browser and web page, that might be slow.

In terms of browser extension, i use copycat.

You can rewrite the source code which provided on Github.