# Simple Python script to download a file. Used as a fallback# when other more reliable methods fail.#from__future__importprint_functionimportsystry:fromrequestsimportgetexceptImportError:try:fromurllib.requestimporturlretrieveUSING="urllib.request.urlretrieve"exceptImportError:try:fromurllibimporturlretrieveUSING="urllib.retrieve"exceptImportError:print("Python at",sys.executable,"is not suitable","for downloading files.",file=sys.stderr)sys.exit(2)else:USING="requests.get"defurlretrieve(url,filename):r=get(url,stream=True)r.raise_for_status()withopen(filename,'wb')asf:forchunkinr.iter_content(chunk_size=1024):f.write(chunk)returnfilenameif__name__=='__main__':iflen(sys.argv)!=3:print("Usage: urlretrieve.py [url] [filename]",file=sys.stderr)sys.exit(1)URL=sys.argv[1]FILENAME=sys.argv[2]print("Downloading from",URL,"to",FILENAME,"using",USING)urlretrieve(URL,FILENAME)