Python urllib download pdf






















By the way, the reason you are only getting a 15kb download is because your url is wrong. It should be. Stack Overflow for Teams — Collaborate and share knowledge with a private group.

Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 8 years, 9 months ago. Active 4 years, 5 months ago. Viewed 7k times.

Add a comment. Active Oldest Votes. Wow, that just seems weird, thanks for telling me about requests though. Trying to do this and all I get is an unreadable. Arjunsingh Arjunsingh 6 6 silver badges 16 16 bronze badges.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Email Required, but never shown. The Overflow Blog. Asked 7 years, 4 months ago. Active 11 months ago. Viewed 53k times. I am trying to download a pdf file from a website using urllib. What am I doing wrong? Probably, you should first check the HTTP response code getcode. This might provide some clue. If all is OK at http-level, we have to look elsewhere.

Have you tried to download a PDF from an other source? To copy to a local file use urlretrieve — stark. Add a comment. Active Oldest Votes. Shivaraj 5 5 silver badges 16 16 bronze badges. As noted by shockburner, you need to use open "document. This can work in python3 as well. All you have to do is change urllib2 to urllib. I tried it, but it still don't work. When I try to open the pdf file, I get an error message saying that the file type is not supported or that the file is damaged.

Odd, it works for me. Even your original code works for me without the 'b'. Can you download the pdf in a browser and open it normally. If you can then you should also include you python and urllib version with print urllib. You might also want to try urllib2 instead of urllib. When I clicked URL I found on a website, it directly started downloading without loading me to another website. Try to use urllib. Thanks it helped me. Piyush Rumao Piyush Rumao 3 3 silver badges 7 7 bronze badges.

I would suggest using following lines of code import urllib. Sign up or log in Sign up using Google.



0コメント

  • 1000 / 1000