I get this error when I attempt to download a file from a link I get this error no matter what I try and look up and to do Im using
urllib.error.HTTPError: HTTP Error 403: Forbidden
My code is
elif message.content.startswith('``'):
countn = (count+1)
print(countn)
print('ADD')
meme = (message.content)
memen = meme.replace("``", "")
print(memen)
print('Converted')
urllib.request.urlretrieve(memen, meme)
await client.send_message (message.channel, "Added!")
403: FORBIDDEN means that the server is denying you access to the resources, either because you have failed to supply sufficient authentication or because it blocks the default python user agent (
Python.urllib/3.X
).urlretrieve is actually a legacy interface as it was ported from Python 2. You should consider using
urlopen
instead.Anyway, one solution to this is to add a (spoofed) user-agent to your request, which can't be done using urlretrieve...
This wont fix issues for sites that require a login, but it will fix a lot of sites that don't.