Reputation: 1394
This is all my code. It's giving me a 403 forbidden error, even though if I type the same URL into google, I get the data.
import urllib.request, json
with urllib.request.urlopen('https://pokeapi.co/api/v2/pokemon/1') as url:
data = json.loads(url.read().decode())
print(data)
Upvotes: 0
Views: 297
Reputation: 691
if I use the requests module, it works
import requests
response = requests.get('https://pokeapi.co/api/v2/pokemon/')
for i in response: print(i)
Upvotes: 4