Download file from web in Python 3

前端 未结 9 697
星月不相逢
星月不相逢 2020-11-22 16:43

I am creating a program that will download a .jar (java) file from a web server, by reading the URL that is specified in the .jad file of the same game/application. I\'m usi

9条回答
  •  青春惊慌失措
    2020-11-22 17:12

    from urllib import request
    
    def get(url):
        with request.urlopen(url) as r:
            return r.read()
    
    
    def download(url, file=None):
        if not file:
            file = url.split('/')[-1]
        with open(file, 'wb') as f:
            f.write(get(url))
    

提交回复
热议问题