Skip to content

Instantly share code, notes, and snippets.

@cosme12
Created August 31, 2018 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosme12/9c843bb0fb0c5531f40ea0607bee3e04 to your computer and use it in GitHub Desktop.
Save cosme12/9c843bb0fb0c5531f40ea0607bee3e04 to your computer and use it in GitHub Desktop.
Ejemplo de como usar Requests
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