Skip to content

Instantly share code, notes, and snippets.

@Gerzer
Created June 27, 2015 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gerzer/cce8d1383194d5495298 to your computer and use it in GitHub Desktop.
Save Gerzer/cce8d1383194d5495298 to your computer and use it in GitHub Desktop.
Import URL.py
# coding: utf-8
import appex
import requests
def main():
if not appex.is_running_extension():
print 'Running in Pythonista app, using test data...\n'
url = 'http://example.com'
else:
url = appex.get_url()
if url:
out_file = open(url.split('/')[-1], 'wb')
out_file.write(requests.get(url).content)
out_file.close()
else:
print 'No input URL found.'
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment