码迷,mamicode.com
首页 > Windows程序 > 详细

set up custom search api

时间:2014-09-07 12:19:35      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   for   cti   sp   on   c   amp   

sign up google developer console, create project, generate API key

http://stackoverflow.com/questions/4082966/google-web-search-api-deprecated-what-now/11206266#11206266

 

Example Code: cx is custom search engine key, developer key is api key

"""Simple command-line example for Custom Search.

Command-line application that does a search.
"""

__author__ = ‘jcgregorio@google.com (Joe Gregorio)‘

import pprint

from apiclient.discovery import build


def main():
# Build a service object for interacting with the API. Visit
# the Google APIs Console <http://code.google.com/apis/console>
# to get an API key for your own application.
service = build("customsearch", "v1",
developerKey="AIzaSyAWk-vGpPYOAktOeXv-XeDTleoiBffrVlU")

res = service.cse().list(
q=‘chemical spill west virginia‘,
cx=‘008308517875943079687:j1fqrkb1_yi‘,
).execute()
pprint.pprint(res)

if __name__ == ‘__main__‘:
main()

set up custom search api

标签:http   io   ar   for   cti   sp   on   c   amp   

原文地址:http://www.cnblogs.com/wintor12/p/3960286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!