0

Fix for "urllib.error.HTTPError: HTTP Error 400: Bad Request"

I ran into this error whenever I'm using urllib.request urllretrieve to download some pdf files and it seems it only appears for some links only because other links are working fine without that error. How do I get rid of it

15th Aug 2018, 3:23 PM
Toni Sedjoah
Toni Sedjoah - avatar
6 Respostas
+ 3
It’s a problem in the other end. It just one of the many http errors.
15th Aug 2018, 4:03 PM
Toni Isotalo
Toni Isotalo - avatar
+ 2
Without code or context of how and when that error is returned. Hard to help you. Though I'd suggest using "requests" rather than urllib/urllib2 http://docs.python-requests.org/en/latest/index.html
15th Aug 2018, 3:56 PM
Chihiro Kanai
Chihiro Kanai - avatar
+ 1
Thanks very much Chihiro
15th Aug 2018, 4:06 PM
Toni Sedjoah
Toni Sedjoah - avatar
+ 1
okay, so if I'm to switch to request, how will I use request to download a file, specifically a pdf file
15th Aug 2018, 4:06 PM
Toni Sedjoah
Toni Sedjoah - avatar
+ 1
Thanks very much, Toni Isotalo
15th Aug 2018, 4:10 PM
Toni Sedjoah
Toni Sedjoah - avatar