Skip to content

Instantly share code, notes, and snippets.

@jorgemdnt
Created October 16, 2016 22:58
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 jorgemdnt/471fe9817dc417985fb0f6a6fc313cb4 to your computer and use it in GitHub Desktop.
Save jorgemdnt/471fe9817dc417985fb0f6a6fc313cb4 to your computer and use it in GitHub Desktop.
# 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