Editorial Workflows

Links from URLs

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Finds all web URLs in the current document and generates a list of Markdown links, using the titles of the web pages (as it would be shown in a browser).

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Document Text ?
Folded Text
  • Include
  • Replace with:
Extract URLs ?
Output
  • Only URLs
  • URLs and Ranges (Separated by Tab)
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import editor
from mechanize import Browser
import console

def main():
	web_urls = filter(lambda s: s.startswith('http'), workflow.get_input().splitlines())
	if not web_urls:
		console.hud_alert('No URLs found', 'error')
		workflow.stop()
		return
	links = []
	for i, url in enumerate(web_urls):
		console.show_activity('Getting titles (%i/%i)' % (i+1, len(web_urls)))
		try:
			br = Browser()
			br.open(url)
			title = br.title()
		except:
			title = ''
		links.append('[%s](%s)' % (title, url))
	console.hide_activity()
	workflow.set_output('\n'.join(links))

main()
Show Alert ?
Title
Generated Links
Message
Input
Button 1
Copy
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
ON
Set Clipboard ?
Show HUD ?
HUD Text
Copied
Duration
  • 1 Second
  • 2 Seconds
  • 3 Seconds
Icon
  • "Success"
  • "Error"