-
Notifications
You must be signed in to change notification settings - Fork 0
/
pokemon.py
38 lines (29 loc) · 879 Bytes
/
pokemon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
ejemplo consumir una api
uso pokemon.py -n #numeroPokedex
"""
import requests
import json
import argparse
import os
import sys
sys.path.append(os.path.join(sys.path[0], "../"))
if __name__ == '__main__':
url = 'https://pokeapi.co/api/v2/pokemon/'
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument("-n", type=str, help="Numero Pokedex")
args = parser.parse_args()
form = args.n
fin = url + form
response = requests.get(fin) #creamos un objeto llamado repon
print(response.url)
if response.status_code == 200:
"""
response_json = response.json() #Diccionario
origin = response_json['origin']
print(origin)
"""
# response_json = json.loads(response.text)
# origin = response_json['origin']
content = response.content
print(content)