Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grab the title of a web article within Automator workflow

Tags:

automator

I am trying to create a workflow that converts a list of URLs into plain text using Instapaper, and then saves the text in text documents on my machine.

So far, I have been able to grab the list of URLs, convert them, and save text documents. The problem is that I can't figure out how to use the name of each web page as the name of the subsequent document.

I use my Instapaper RSS URL to grab the articles. Then I use "Get Link URLs from Articles" followed by an Applescript to convert to the plain text version. "Get Text from Webpage" grabs the text. "New Text File" allows me to save each document, but they all have the same name, the one I entered into the Save As input in the New Text File action.

How might I have that action save the documents as each webpage's title?

like image 887
Ed. Avatar asked Jan 24 '26 19:01

Ed.


1 Answers

If you pass this AppleScript a URL it should return the title of the page...

on run {input, parameters}
    set pageTitle to do shell script "curl " & quoted form of (first item of input) & " | grep -o \\<title\\>.*\\</title\\> | sed -E 's/<\\/?title>//g'"
    return pageTitle
end run
like image 169
adayzdone Avatar answered Jan 29 '26 18:01

adayzdone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!