Skip to content

Instantly share code, notes, and snippets.

@jorgemdnt
Created October 17, 2016 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jorgemdnt/223938e6642017147669524f8fb34f3f to your computer and use it in GitHub Desktop.
Save jorgemdnt/223938e6642017147669524f8fb34f3f to your computer and use it in GitHub Desktop.
# coding=utf-8
from urllib import urlencode
from star_wars.exceptions import PersonagemNaoEncontradoException
# [...] StarWarsGatewaySWAPI
def buscar_personagem(self, nome):
recurso = 'people/?'
parametros_de_busca = urlencode({'search': nome})
url_completa = self.URL + recurso + parametros_de_busca
response = self.client.get(url_completa)
conteudo = response.json()
if conteudo['count'] == 0:
raise PersonagemNaoEncontradoException(nome)
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment