Download pdf using urllib?

前端 未结 5 849
北海茫月
北海茫月 2020-12-01 05:31

I am trying to download a pdf file from a website using urllib. This is what i got so far:

import urllib

def download_file(download_url):
    web_file = url         


        
5条回答
  •  孤城傲影
    2020-12-01 06:20

    Try to use urllib.retrieve (Python 3) and just do that:

    from urllib.request import urlretrieve
    
    def download_file(download_url):
        urlretrieve(download_url, 'path_to_save_plus_some_file.pdf')
    
    if __name__ == 'main':
        download_file('http://www.example.com/some_file.pdf')
    

提交回复
热议问题