Created
October 16, 2016 22:58
-
-
Save jorgemdnt/471fe9817dc417985fb0f6a6fc313cb4 to your computer and use it in GitHub Desktop.
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
# coding=utf-8 | |
import requests | |
from urllib import urlencode | |
class StarWarsGatewaySWAPI(object): | |
URL = 'http://swapi.co/api/' | |
def buscar_dados(self): | |
return requests.get(self.URL) | |
def buscar_personagem(self, nome): | |
recurso = 'people/?' | |
# traduz nosso dicionário python nos parametros de busca HTTP | |
parametros_de_busca = urlencode({'search': nome}) | |
url_completa = self.URL + recurso + parametros_de_busca | |
return requests.get(url_completa) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment