本文整理汇总了Python中product.Product.get_rating方法的典型用法代码示例。如果您正苦于以下问题:Python Product.get_rating方法的具体用法?Python Product.get_rating怎么用?Python Product.get_rating使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product.Product
的用法示例。
在下文中一共展示了Product.get_rating方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_search_sanity
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get_rating [as 别名]
def test_search_sanity(self):
our_products = []
products = self.seach.search(self.product_group, self.keyword)
our_products_item = self.api.item_search(self.product_group, Keywords=self.keyword)
for index, item in enumerate(our_products_item):
if index == self.MAX_RESULTS:
break
browse_nodes = self.api.item_lookup(ItemId=item.ASIN, ResponseGroup='OfferListings,\
BrowseNodes,\
OfferSummary,\
Offers,\
Images')
product = Product(item, browse_nodes)
if (product.get_img_url('SmallImage') == 'null') or \
(product.get_img_url('MediumImage') == 'null' and product.get_img_url('LargeImage') == 'null'):
index -= 1
continue
if product.get_rating() == 'null' or \
product.get_review() == 'null' or product.get_price() == 'null':
index -= 1
continue
our_products.append(product)
products_ASIN = [product.ASIN for product in products]
our_products_ASIN = [product.ASIN for product in our_products]
self.assertItemsEqual(products_ASIN,our_products_ASIN)
示例2: search
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import get_rating [as 别名]
def search(self, product_group, keyword, browse_node=None):
"""
:param product_group: search_index(string)
:param keyword: free keyword (string)
:return: list of Products instance
"""
product_items = self.api.item_search(product_group, Keywords=keyword, BrowseNode=browse_node)
products = []
index = -1
for item in product_items:
index += 1
if index == self.MAX_RESULTS:
break
browse_nodes = self.api.item_lookup(ItemId=item.ASIN, ResponseGroup='OfferListings,\
BrowseNodes,\
OfferSummary,\
Offers,\
Images')
product = Product(item, browse_nodes)
if (product.get_img_url('SmallImage') == 'null') or \
(product.get_img_url('MediumImage') == 'null' and product.get_img_url('LargeImage') == 'null'):
index -= 1
continue
if product.get_rating() == 'null' or product.get_review() == 'null' or product.get_price() == 'null':
index -= 1
continue
if float(product.get_rating()) < 4.0:
index -= 1
continue
products.append(product)
return products