on-internet
← Community

Download pdf using urllib?

Stack Overflow ·

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 = urllib.urlopen(download_url) local_file = open('some_file.pdf', 'w') local_file.write(web_file.read()) web_file.close() local_file.close() if __name__ == 'main': download_file('http://www.example.com/some_file.pdf') When i run this code, all I get is an empty pdf file. What am I doing wrong?

Comments

Sign in or sign up to comment and upvote.

No comments yet.