def get_products_by_keyword(self, keyword, offset=0, limit=100): self.log.debug('get_products_by_keyword') product_api = Products() try: total_count = product_api.get_products_count_by_keyword(keyword) except Exception as e: self.log.error( "Exception when calling get_products_count_by_keyword: %s\n" % e) try: products = product_api.get_products_by_keyword(keyword, only_text=False, offset=offset, limit=limit) except Exception as e: self.log.error( "Exception when calling get_products_by_keyword: %s\n" % e) return total_count, products
api_instance = Products() try: # api_response = api_instance.get_products_by_keyword('Coat', only_text=True, is_processed_for_text_class_model=False, offset=0, limit=100) # pprint(api_response) keyword = 'coat' test_str = 'coating' offset = 0 limit = 100 while True: api_response = api_instance.get_products_by_keyword( keyword, only_text=True, is_processed_for_text_class_model=False, offset=offset, limit=limit) # pprint(api_response) for res in api_response: name = res.get('name') if test_str in name: pprint(test_str + ' in keyword: ' + keyword) pprint(name) pprint(res.get('cate')) pprint(res.get('tags')) if limit > len(api_response): break