Pythonista Trick: URL to Markdown

September 14, 2012 by Gabe | [mmd] |

Here's a nice little tool I made in Pythonista for iOS (review). This script is using Brett Terpstra's awesome heckyesmarkdown web service, which is extremely useful and underrated.

To use this script, I copy a URL to the iOS clipboard and jump into Pythonista. I trigger this script to get the web page in Markdown encoded text.

This URL:

is turned into plain text and put back on the clipboard. The results are displayed in a popup Pythonista browser window:

Here's the script:

import clipboard
import urllib2
import webbrowser

clipString = clipboard.get()

marky = ''

queryString = marky + clipString

reqMD = urllib2.Request(queryString)
openMD = urllib2.urlopen(reqMD)
content = ('utf-8'))

The script started life with a mess of URL validations steps, but Brett's service is so awesome that it just fails gracefully with bad URL's. But I did try out the new Pythonista console.alert() method. I like it.

blog comments powered by Disqus