Return to Snippet

Revision: 12505
at March 17, 2009 15:58 by tamuratetsuya


Initial Code
#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

Initial URL

                                

Initial Description

                                

Initial Title
googleの検索結果数を取得

Initial Tags
google, python, django

Initial Language
Python