Skip to content

Commit 4ac4f9e

Browse files
authored
Merge pull request mouredev#3807 from pyramsd/reto#20
#20 - python
2 parents f96c320 + f1a2bf6 commit 4ac4f9e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import requests
2+
from colorama import Fore
3+
4+
query = requests.get('https://comandos-de-linux.reflex.run/')
5+
6+
statusCode = query.status_code
7+
8+
if statusCode == 200:
9+
print(Fore.GREEN + "[+] Petición exitosa" + Fore.RESET)
10+
print(query.content.decode('utf-8'))
11+
else:
12+
print(Fore.RED + "[-] Algo salió mal!" + Fore.RESET)
13+
14+
'''
15+
EXTRA
16+
'''
17+
baseURL = "https://pokeapi.co/api/v2/pokemon"
18+
def getDataPokemon(name):
19+
url = baseURL + "/" + name
20+
try:
21+
query = requests.get(url)
22+
query.raise_for_status()
23+
data = query.json()
24+
25+
print(f"Name: {data['name']}")
26+
print(f"ID: {data['id']}")
27+
print(f"Weight: {data['weight']}")
28+
print(f"Height: {data['height']}")
29+
print(f"Types: {''.join([i['type']['name'] for i in data['types']])}")
30+
print(f"Games: {[game['version']['name'] for game in data['game_indices']]}")
31+
32+
33+
except requests.exceptions.HTTPError as e:
34+
if query.status_code == 404:
35+
print(Fore.RED + f"[-] Error 404: Pokemon '{name}' Not found" + Fore.RESET)
36+
37+
name = input("Nombre de pokemon: ")
38+
getDataPokemon(name)

0 commit comments

Comments
 (0)