Posted By

tamuratetsuya on 03/17/09


Tagged

google python engine app django


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ricardodapaz


googleの検索結果数を取得


 / Published in: Python
 

  1. #googleの検索結果数を見る
  2. def countWord(word):
  3. q = {#'q':'\"'+question+'\"',
  4. 'q':word.encode('utf-8'),
  5. 'v' : 1.0,
  6. 'hl' : 'ja',
  7. 'rsz': 'small'
  8. }
  9. url=u'http://ajax.googleapis.com/ajax/services/search/web?'+ urllib.urlencode(q)
  10. json_result=urlfetch.fetch(url).content
  11. json_result = string.replace(json_result, 'null', '"null"')
  12. try:
  13. dict_result=eval('dict('+json_result+')')
  14. return dict_result['responseData']['cursor']['estimatedResultCount']
  15. except:
  16. return 0

Report this snippet  

You need to login to post a comment.