Advertisement
KeiroKamioka

Untitled

Sep 2nd, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. # coding: shift-jis
  2. import codecs
  3. import sys
  4. import urllib
  5. import urllib2
  6. import re, pprint
  7.  
  8. errorCheck = "0"
  9. isbn = raw_input("Enter IBSN Number Please ")
  10. isIsbn = len(isbn)
  11.  
  12.  
  13. if isIsbn == 10 or isIsbn == 13:
  14. errorCheck = 1;
  15. print "isbn"
  16.  
  17. url = "http://iss.ndl.go.jp/api/opensearch?isbn=%s" % isbn
  18. req = urllib2.Request(url)
  19. response = urllib2.urlopen(req)
  20. result = response.read()
  21. print(result)
  22.  
  23. def pp(result):
  24. if isinstance(result, list) or isinstance(result, dict):
  25. orig = json.dumps(result, indent=4)
  26. print eval("u'''%s'''" % orig).encode('shift-jis')
  27. else:
  28. print result
  29.  
  30.  
  31.  
  32. if errorCheck == "0":
  33. print "It is not ISBN"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement