аватар question@mail.ru · 01.01.1970 03:00

Download file via urllib

Tell me, please, how to download the file by Python (urllib) Available in http and put it next to the script?

аватар answer@mail.ru · 01.01.1970 03:00

urllib -& gt; URLOPEN - opens the file at the reading link given to him, then you can simply count it Read (), open the binary record file, and write down in it what you read on HTTP. Example of downloading emblem:

   Import  urlliblogo = urllib.urlopen ( "" http://www.google.com/images/srPR/logo3w.png "" ). Read () f =  open  ( "" logo3w.png "" ,  "wb" ") f.write (logo) f.close ()       
   import  urllibdestination =  'logo3w.png'  url =  'http://www.google.com/images/srPr/logo3w.png'  urllib.urlretreeve (URL, Destination)                                       

Latest

Similar