/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#googleã®æ¤œç´¢çµæžœæ•°ã‚’見る def countWord(word): q = {#'q':'\"'+question+'\"', 'q':word.encode('utf-8'), 'v' : 1.0, 'hl' : 'ja', 'rsz': 'small' } url=u'http://ajax.googleapis.com/ajax/services/search/web?'+ urllib.urlencode(q) json_result=urlfetch.fetch(url).content json_result = string.replace(json_result, 'null', '"null"') try: dict_result=eval('dict('+json_result+')') return dict_result['responseData']['cursor']['estimatedResultCount'] except: return 0