Created
June 27, 2015 14:52
-
-
Save Gerzer/cce8d1383194d5495298 to your computer and use it in GitHub Desktop.
Import URL.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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