Erreur 403 only with Python

Avatar image for ludalito
ludalito

2

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By ludalito

Hello,

I'd like to use the API in Python but I keep having a 403 error response.

import requests API_KEY_COMIC_VINE = "myApiKey" request_comicvine = "http://comicvine.gamespot.com/api/search/?api_key=" + API_KEY_COMIC_VINE + "&query=antares" response = requests.get(request_comicvine) print(response.status_code)

> 403

But the same URL in my browser gives me the right answer. Anybody have an idea of the problem ?

I tried the same code with others API (TheMovieDB for example) and it works fine...

https://comicvine.gamespot.com/api/search/?api_key=myApiKey&query=antares


Avatar image for debrej
Debrej

1

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Hey,

I've had the same problem, I checked the requests headers to see if there was any difference. I think that changing the User-Agent header to a navigator header works. I put mine to a Mozilla header and it responded.

Avatar image for deactivated-626a6ab2359e8
deactivated-626a6ab2359e8

3

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

Avatar image for driftsam7
driftSam7

2

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@ludalito:
I think I'm having the same issue. When I try to hit the api from my app I'm getting a 403 Forbidden and some html that talks about "Wordpress RSS Reader, Anonymous Bot or Scraper Blocked"

Did @debrej's solution about changing the User-Agent in the request header work for you?

Avatar image for wonderous350
wonderous350

50

Forum Posts

3

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

@debrej: @driftsam7: @alsapone:

I had this issue as well, the thing that fixes it is putting something useful in the user-agent header field when making a request. If you leave it at the default for python - the API will not allow you to make the request. Change it to something like the following:

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36'}