Urlretrieve return typeerror

I don’t know why my code returns this error, I cannot debug it.

TypeError: expected string or bytes-like object

Here is what I use to download

self.headers = { 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }
self.request = urllib.request.Request(url, headers=self.headers)
urllib.request.urlretrieve(self.request, reporthook=report)
+1
source share
1 answer

It urlretrievedoesn't seem to allow sending headers.

And the error you get is that the urlretrieveURL is expecting, not the object Request.

Since your own web server is sending the request, perhaps you can change its configuration to accept those requests urlretrievewithout headers.

Good luck.

+1
source

Source: https://habr.com/ru/post/1682005/


All Articles