This is simple example to use request for downloading the files.
import urllib
import sys
#adding the requests http://docs.python-requests.org/en/latest/index.html
import requests
print sys.argv[1]
# url to download
r=requests.get(sys.argv[1])
with open(sys.argv[2],"wb") as code:
#argv[2] is target file name
code.write(r.content)
here, argv[1] is the link for the download file ( ex.- https://google.com)
and argv[2] is the target file (ex. google.html).
run it by
#python script.py http://google.com google.html
happy coading :) B-)
Reference:
download code from git
http://docs.python-requests.org/en/latest/
No comments:
Post a Comment