Skip to content

Instantly share code, notes, and snippets.

@hirokiky
Last active August 29, 2015 14:01
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 hirokiky/768b636c2870778b29f5 to your computer and use it in GitHub Desktop.
Save hirokiky/768b636c2870778b29f5 to your computer and use it in GitHub Desktop.
Get a LGHT picture from LGTM.in ramdomly
#! /usr/bin/env python
"""
Get a LGHT picture from LGTM.in ramdomly.
Usage
=====
::
$ ./lgtm.py
Thanks
======
Thanks for @rahulsom to remove unnecessary requiremests:
* http://twitter.com/rahulsom/status/468633736771555328
"""
#! /usr/bin/env python
import json
import urllib2
import webbrowser
LGTMIN_RANDOM_URL = 'http://www.lgtm.in/g'
def get_lgtm_image_url():
req = urllib2.Request(LGTMIN_RANDOM_URL)
req.add_header('Accept', ['application/json'])
res = urllib2.urlopen(req)
return json.loads(res.read())['imageUrl']
if __name__ in ('main', '__main__'):
webbrowser.open(get_lgtm_image_url())
@hirokiky
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment