Guest User

Untitled

a guest
Nov 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. import requests
  2. import json
  3. from operator import itemgetter
  4. from collections import OrderedDict
  5.  
  6. def requisicao(nome):
  7. try:
  8. req = requests.get('http://www.omdbapi.com/?apikey=5b5be94f&type=movie&s='+nome)
  9. return req
  10. except:
  11. print('Erro de conexão')
  12. return None
  13.  
  14.  
  15. while True:
  16. nome = input('Digite o nome do filme ou EXIT para sair: ')
  17. if nome == 'EXIT':
  18. exit()
  19. else:
  20. result = requisicao(nome)
  21. dic = json.loads(result.text)
  22. #OrderedDict(sorted(dic.items(), key=lambda t: t[1]))
  23. for i in dic['Search']:
  24. print("Titulo: " + i['Title'] + "n" "Ano: " + i['Year'])
Add Comment
Please, Sign In to add comment