Python download file without external library -
i have large python script using pyinstaller create exe. need download xml file keep exe small possible getting quite large.
is there method within python file url? not able find without external library
you can use urllib.urlretrieve() saves opened page specified path.
alternatively can open url urllib.urlopen() , write read file in binary mode:
import urllib urllib.urlretrieve(url, destination_path) # first , short way open(destination_path, 'wb') f: # equivalent first, longer f.write(urllib.urlopen(url).read())
Comments
Post a Comment