Created
January 22, 2015 21:40
-
-
Save gabrielfalcao/ea461138f0879cb2fa5b to your computer and use it in GitHub Desktop.
This file contains 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 | |
# -*- coding: utf-8 -*- | |
# | |
from __future__ import unicode_literals | |
import os | |
import sys | |
import requests | |
url = 'http://ajax.googleapis.com/ajax/services/search/images' | |
def search(name): | |
params = { | |
'v': '1.0', | |
'rsz': '8', | |
'q': '{0} github'.format(name), | |
'safe': 'active', | |
'imgtype': 'face' | |
} | |
response = requests.get(url, params=params) | |
data = response.json() | |
results = data['responseData']['results'] | |
return results[0]['unescapedUrl'] | |
def utf8(s): | |
return s.decode('utf-8') | |
if __name__ == '__main__': | |
name = " ".join(map(utf8, sys.argv[1:])) | |
url = search(name) | |
os.system('open {0}'.format(url)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
USAGE: