File: fulltextsearch.py

package info (click to toggle)
python-googleapi 1.2-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,196 kB
  • ctags: 1,019
  • sloc: python: 5,827; makefile: 22; sh: 4
file content (40 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python2.4
# -*- coding: utf-8 -*-
#
# Copyright 2010 Google Inc. All Rights Reserved.

"""Full text search query against the shopping search API"""

import pprint

from apiclient.discovery import build


SHOPPING_API_VERSION = 'v1'
DEVELOPER_KEY = 'AIzaSyACZJW4JwcWwz5taR2gjIMNQrtgDLfILPc'


def main():
  """Get and print a feed of all public products matching the search query
  "digital camera".

  This is achieved by using the q query parameter to the list method.

  The "|" operator can be used to search for alternative search terms, for
  example: q = 'banana|apple' will search for bananas or apples.

  Search phrases such as those containing spaces can be specified by
  surrounding them with double quotes, for example q='"mp3 player"'. This can
  be useful when combining with the "|" operator such as q = '"mp3
  player"|ipod'.
  """
  client = build('shopping', SHOPPING_API_VERSION, developerKey=DEVELOPER_KEY)
  resource = client.products()
  # Note the 'q' parameter, which will contain the value of the search query
  request = resource.list(source='public', country='US', q=u'digital camera')
  response = request.execute()
  pprint.pprint(response)


if __name__ == '__main__':
    main()