Last active
August 29, 2015 14:01
-
-
Save hirokiky/768b636c2870778b29f5 to your computer and use it in GitHub Desktop.
Get a LGHT picture from LGTM.in ramdomly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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()) |
Author
hirokiky
commented
May 20, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment