decryptable
decryptable

Reputation: 33

urlretrieve returning typeerror

I don't know why my code is returning this error, I can't seem to debug it.

TypeError: expected string or bytes-like object

Here is what I'm using 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)

Upvotes: 1

Views: 576

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169364

It appears that urlretrieve doesn't allow the sending of headers.

And the error you're getting is because urlretrieve is expecting a URL there and not a Request object.

Since it's your own webserver you're sending the request to maybe you can modify its configuration to accept those urlretrieve requests without headers.

Best of luck.

Upvotes: 1

Related Questions