Created
August 31, 2018 17:51
-
-
Save cosme12/9c843bb0fb0c5531f40ea0607bee3e04 to your computer and use it in GitHub Desktop.
Ejemplo de como usar Requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
r = requests.get('https://api.opendota.com/api/heroes') | |
# Con esto obtenemos todos los datos de la pagina | |
print(r.text) | |
# Ahora tenemos que usar json para parsear los datos. Porque sino tenes un string mega gigante | |
import json | |
# Transformamos todo el muro de texto en un diccionario | |
heroes_dict = json.loads(r.text) | |
# Imprimimos todos los nombres de los heroes | |
for hero in heroes_dict: | |
print(hero['localized_name']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment