Skip to content

Instantly share code, notes, and snippets.

Last active March 28, 2017 18:34
What would you like to do?
Easy pythonista script to use from dropbox iOS app share sheet to take dropbox link to python script and save it to pythonista filesystem. Also works with "raw" python scripts from github and gists.
import requests, appex
from urllib.parse import urlparse
url = appex.get_url().replace("dl=0", "dl=1")
r = requests.get(url)
filename = urlparse(url).path.rpartition("/")[-1].replace(".py", "")
with open(filename, "wb") as outfile:
print("script downloaded as " + filename)
Copy link

cclauss commented Mar 10, 2017

Could be a seven liner ;-) ...

  • Change line 7 to: outfile.write(requests.get(url).content)
  • Delete line 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment