Grab the title of a web article within Automator workflow

为君一笑 提交于 2019-12-10 19:21:02

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/18812209/grab-the-title-of-a-web-article-within-automator-workflow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!