1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# 4# Copyright 2014 Google Inc. All Rights Reserved. 5 6"""Full text search query against the shopping search API""" 7 8import pprint 9 10from googleapiclient.discovery import build 11 12 13SHOPPING_API_VERSION = 'v1' 14DEVELOPER_KEY = 'AIzaSyACZJW4JwcWwz5taR2gjIMNQrtgDLfILPc' 15 16 17def main(): 18 """Get and print a feed of all public products matching the search query 19 "digital camera". 20 21 This is achieved by using the q query parameter to the list method. 22 23 The "|" operator can be used to search for alternative search terms, for 24 example: q = 'banana|apple' will search for bananas or apples. 25 26 Search phrases such as those containing spaces can be specified by 27 surrounding them with double quotes, for example q='"mp3 player"'. This can 28 be useful when combining with the "|" operator such as q = '"mp3 29 player"|ipod'. 30 """ 31 client = build('shopping', SHOPPING_API_VERSION, developerKey=DEVELOPER_KEY) 32 resource = client.products() 33 # Note the 'q' parameter, which will contain the value of the search query 34 request = resource.list(source='public', country='US', q=u'digital camera') 35 response = request.execute() 36 pprint.pprint(response) 37 38 39if __name__ == '__main__': 40 main() 41