Posted By

saturngod on 05/22/11


Tagged


Versions (?)

Get Language from Github


 / Published in: Python
 

  1. import urllib
  2. import urllib2
  3. import json
  4. from StringIO import StringIO
  5.  
  6. access_tocken="Your token"
  7.  
  8. url="http://github.com/api/v2/json/repos/show/saturngod?access_token="+access_tocken
  9. req = urllib2.Request(url)
  10.  
  11. # Your parameter encoding here
  12. req.add_header('User-agent', 'Mozilla/5.0')
  13. repos_raw = urllib2.urlopen(req)
  14. repos=json.load(StringIO(repos_raw.read()))
  15.  
  16. for k in repos['repositories']:
  17. print k['url']
  18. repo_source=k['url'].replace("https://github.com/","")
  19. print repo_source
  20. #language
  21. #http://github.com/api/v2/json/repos/show/mojombo/grit/languages
  22. url="http://github.com/api/v2/json/repos/show/"+repo_source+"/languages?access_token="+access_token
  23. req = urllib2.Request(url)
  24. req.add_header('User-agent', 'Mozilla/5.0')
  25. language_raw = urllib2.urlopen(req)
  26. languages=json.load(StringIO(language_raw.read()))
  27. for write in languages['languages']:
  28. print write
  29.  

Report this snippet  

You need to login to post a comment.