当前位置: 首页>>代码示例>>Python>>正文


Python AmazonAPI.put方法代码示例

本文整理汇总了Python中amazon.api.AmazonAPI.put方法的典型用法代码示例。如果您正苦于以下问题:Python AmazonAPI.put方法的具体用法?Python AmazonAPI.put怎么用?Python AmazonAPI.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在amazon.api.AmazonAPI的用法示例。


在下文中一共展示了AmazonAPI.put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from amazon.api import AmazonAPI [as 别名]
# 或者: from amazon.api.AmazonAPI import put [as 别名]
    def get(self):

        user = users.get_current_user()
        person_id = user.user_id()

        store_type = self.request.get('type')
        product_id = self.request.get('id')

        item_to_add = None

        if store_type.lower() == "walmart":

            logging.info('True for walmart')
            walmart_url=("http://api.walmartlabs.com/v1/items/%s?format=json&apiKey=cz9kfm3vuhssnk6hn33zg86k" %product_id)
            walmart_JSON_string=json.load(urllib2.urlopen(walmart_url))

            walmart_image_source="<img src=%s>" %walmart_JSON_string["thumbnailImage"]

            walmart_name=walmart_JSON_string["name"]

            sales_Price = str(walmart_JSON_string["salePrice"])

            walmart_link_to_buy = walmart_JSON_string["productUrl"]

            walmart_link_to_remove = "/remove?id=%s" %product_id

            walmart_upc = str(walmart_JSON_string["upc"])

            walmart_compare_upc = "/compare?upc=%s" %str(walmart_JSON_string["upc"])


            check_product=WishList.query(WishList.user_id==person_id,WishList.item_id==product_id).get()

            if check_product == None:

                walmart = WishList(user_id = person_id, store = store_type, item_id = product_id,name = walmart_name, price = sales_Price, image = walmart_image_source, url = walmart_link_to_buy,removeUrl=walmart_link_to_remove,upc_id=walmart_upc)
                walmart = WishList(user_id = person_id, store = store_type, item_id = product_id,name = walmart_name, price = sales_Price, image = walmart_image_source, url = walmart_link_to_buy,removeUrl=walmart_link_to_remove,compare_url=walmart_compare_upc)

                walmart.put()
                item_to_add = walmart


        if store_type.lower() == "bestbuy":

            logging.info('True for bestbuy')
            bestbuy_url=("http://api.remix.bestbuy.com/v1/products/%s.json?show=sku,name,salePrice,url,image,upc&apiKey=24ta6vtsr78a22fmv8ngfjet" %product_id)
            bestbuy_JSON_string=json.load(urllib2.urlopen(bestbuy_url))

            bestbuy_image_source="<img src=%s>" %bestbuy_JSON_string["image"]

            bestbuy_name=bestbuy_JSON_string["name"]

            bestbuy_Price = str(bestbuy_JSON_string["salePrice"])

            bestbuy_link_to_buy = bestbuy_JSON_string["url"]

            bestbuy_link_to_remove = "/remove?id=%s" %product_id

            bestbuy_upc = str(bestbuy_JSON_string["upc"])

            check_product=WishList.query(WishList.user_id==person_id,WishList.item_id==product_id).get()
            if check_product == None:
                bestbuy = WishList(user_id = person_id, store = store_type, item_id = product_id,name = bestbuy_name, price = bestbuy_Price, image = bestbuy_image_source, url = bestbuy_link_to_buy,removeUrl=bestbuy_link_to_remove,upc_id = bestbuy_upc,bestbuy_compare_upc = "/compare?upc=%s" %str(bestbuy_JSON_string["upc"]))

            check_product=WishList.query(WishList.user_id==person_id,WishList.item_id==product_id).get()
            if check_product == None:
                bestbuy = WishList(user_id = person_id, store = store_type, item_id = product_id,name = bestbuy_name, price = bestbuy_Price, image = bestbuy_image_source, url = bestbuy_link_to_buy,removeUrl=bestbuy_link_to_remove,compare_url = bestbuy_compare_upc)

                bestbuy.put()
                item_to_add = bestbuy

        if store_type.lower() == "amazon":
            amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG) #initiates a new Amazon API
            product = amazon.lookup(ItemId='%s' %product_id)

            amazon_image_source="<img src=%s>" %product.medium_image_url

            amazon_name=product.title

            amazon_Price = str(product.price_and_currency[0])

            amazon_link_to_buy = product.offer_url

            amazon_link_to_remove = "/remove?id=%s" %product_id

            amazon_upc = str(product.upc)

            check_product=WishList.query(WishList.user_id==person_id,WishList.item_id==product_id).get()
            if check_product == None:
                amazon = WishList(user_id = person_id, store = store_type, item_id = product_id,name = amazon_name, price = amazon_Price, image = amazon_image_source, url = amazon_link_to_buy,removeUrl=amazon_link_to_remove,upc_id = amazon_upc)

            amazon_Price = str(product.price_and_currency[0])

            amazon_link_to_buy = product.offer_url

            amazon_link_to_remove = "/remove?id=%s" %product_id

            amazon_compare_upc = "/compare?upc=%s" %str(product.upc)

            check_product=WishList.query(WishList.user_id==person_id,WishList.item_id==product_id).get()
#.........这里部分代码省略.........
开发者ID:gegbo,项目名称:lowest_current_deals,代码行数:103,代码来源:main.py


注:本文中的amazon.api.AmazonAPI.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。