google-assistant-sdk/googlesamples/assistant/grpc/image_search.py
def search(self, query, num=10):
    """searches for images by a query"""
    res = []
    try:
        response = self.__search.cse().list(
            q=query,
            cx=self.custom_search,
            num=num,
            searchType='image',
            safe='high',
            start=0).execute()
        if response and 'items' in response:
          res.extend([item['link'] for item in response['items'] if 'link' in item])
    except Exception:
      logging.exception('Generic exception')
    return res
searches for images by a query
searches for images by a query
searches for images by a query
def search(self, query, num=10):
    res = []
    try:
        response = self.__search.cse().list(
            q=query,
            cx=self.custom_search,
            num=num,
            searchType='image',
            safe='high',
            start=0).execute()
        if response and 'items' in response:
          res.extend([item['link'] for item in response['items'] if 'link' in item])
    except Exception:
      logging.exception('Generic exception')
    return res
def search ( self , query , num = 10 ) : res = [ ] try : response = self . __search . cse ( ) . list ( q = query , cx = self . custom_search , num = num , searchType = 'image' , safe = 'high' , start = 0 ) . execute ( ) if response and 'items' in response : res . extend ( [ item [ 'link' ] for item in response [ 'items' ] if 'link' in item ] ) except Exception : logging . exception ( 'Generic exception' ) return res
searches for images by a query
searches for images by a query
"""searches for images by a query"""
self
query
num