How to Download a file to a specific path in the server : Python

前端 未结 2 1408
小蘑菇
小蘑菇 2021-01-14 06:31

How to download a file through http on to a local folder on my server in jython(or python)

The below code might work

os.chdir(\"/path/to/change/to\"         


        
相关标签:
2条回答
  • 2021-01-14 07:09

    How about urllib.urlretrieve

    import urllib
    urllib.urlretrieve('http://python.org/images/python-logo.gif', '/tmp/foo.gif')
    
    0 讨论(0)
  • 2021-01-14 07:10

    Use open(..., 'wb') to open the file where you like, urllib2.urlopen() to open the network resource, and shutil.copyfileobj() to copy from one to the other.

    0 讨论(0)
提交回复
热议问题