代码已上传 https://github.com/jevy146/keepa

1.https://keepa.com/#! 这个是keepa的官网,首先你需要注册购买其服务。相对于他能提供的亚马逊的大量数据,这些钱花的超值。
2.这里以日本站的数据获取为例。
https://www.amazon.co.jp/dp/B003G357L0
在这个插件中你可以获取历史的排名以及价格、评论的变化情况。

3.这里使用的是Python调用其API的数据,keepa的首席执行官给的开源文档是java写的,,果然java才是最强的编程语言。亚马逊后台给的API接口用的是php,java和.Net。
这里放出来的是亚纳逊的官方API开发文档接口:欢迎大家参与交流。
http://docs.developer.amazonservices.com/zh_CN/orders/2013-09-01/Orders_GetOrder.html
我收集的亚马逊对接api的链接,也有大佬用Python封装了接口

1. http://docs.developer.amazonservices.com/zh_CN/fba_outbound/FBAOutbound_Overview.html官方
2.https://blog.csdn.net/zhou_xtao/article/details/96109682
3.https://github.com/jevy146/amazon-demo  使用java调用亚马逊的API数据
4.https://github.com/mystudytime/easy-amazon-advertising  亚马逊对接广告数据
5.https://www.crifan.com/python_amazon_aws_api_lib_framework/ 调用api文档

4.进入正题:
这个是keepa官方给出的api接口代码。
https://github.com/keepacom/api_backend/

按照正常的操作:传入参数,相应的结果如下链接所示。这里作为java仅能看懂的菜鸟不作展开。
https://keepa.com/#!discuss/t/product-object/116
5.下面介绍以为Python语言的福音。有为大佬带着拯救世界的步伐过来了。
https://github.com/akaszynski/keepa

看到这个开源的代码,我的眼泪就要流下来了,好吧!
我们pip install keepa 安装这个包。包不算大。
查看其源码的,主要用的这个类和
parse_csv这个函数。

6.那我们就按照大佬的代码走一遍。
首先去官网拿到你的api的钥匙,原谅我这里打上马赛克。。一个月15刀。
https://keepa.com/#!api


7.这里由于用的是日文,我就将作者的代码稍微修改了一下。已知大佬用的是Python中的matplotlib画图。
源码里面有。那就好办了。

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
import keepa
#https://keepa.com/#!api  keepa数据的api
# enter real access key here
accesskey = '*****输入你自己的api钥匙******'
#这里可以添加参数,后面再说。
api = keepa.Keepa(accesskey)
# Single ASIN query
products = api.query('B003G357L0',domain='JP') # returns list of product data
keepa.plot_product(products[0])


运行要花一些时间。
运行结果:这里我分段截图



这里我补充一下。
当你发送 api.query(‘B003G357L0’,domain=‘JP’)的请求时,keepa响应的结结果products是一个列表长度为1,这里我怎么说呢,我将这个数据保存到本地:

file=open('./out.txt','w',encoding="utf-8")
file.write(str(products[0]))
file.close()


这里获取products[0]的数据,里面就是一个字典了。

https://keepa.com/#!discuss/t/request-products/110/1 这里是官方给出请求参数的介绍
字典里面包含了很多信息。

这里你估计会想:我操这都是什么鬼,官方文档里面给出的我就不说了,这里说一下keepa这个包作者的思路。也就是这两个键的值

这里你不需要去解析product[‘csv’],作者是将这个解析了的,然后放到
product[‘data’]里面了。
我为啥这么说呢?我们看源码:这里作者使用parse_csv() 这个函数解析的。

我们看一下这个函数,源码我贴上来,这里传入一个列表(csv)


def parse_csv(csv, to_datetime=True, out_of_stock_as_nan=True):"""Parses csv list from keepa into a python dictionary.Parameters----------csv : listcsv list from keepato_datetime : bool, optionalModifies numpy minutes to datetime.datetime values.Default True.out_of_stock_as_nan : bool, optionalWhen True, prices are NAN when price category is out of stock.When False, prices are -0.01Default TrueReturns-------product_data : dictDictionary containing the following fields with timestamps:AMAZON: Amazon price historyNEW: Marketplace/3rd party New price history - Amazon isconsidered to be part of the marketplace as well, so ifAmazon has the overall lowest new (!) price, themarketplace new price in the corresponding time intervalwill be identical to the Amazon price (except if there isonly one marketplace offer).  Shipping and Handling costsnot included!USED: Marketplace/3rd party Used price historySALES: Sales Rank history. Not every product has a Sales Rank.LISTPRICE: List Price history5 COLLECTIBLE: Collectible Price history6 REFURBISHED: Refurbished Price history7 NEW_FBM_SHIPPING: 3rd party (not including Amazon) New pricehistory including shipping costs, only fulfilled bymerchant (FBM).8 LIGHTNING_DEAL:  3rd party (not including Amazon) New pricehistory including shipping costs, only fulfilled bymerchant (FBM).9 WAREHOUSE: Amazon Warehouse Deals price history. Mostly ofused condition, rarely new.10 NEW_FBA: Price history of the lowest 3rd party (notincluding Amazon/Warehouse) New offer that is fulfilledby Amazon11 COUNT_NEW: New offer count history12 COUNT_USED: Used offer count history13 COUNT_REFURBISHED: Refurbished offer count history14 COUNT_COLLECTIBLE: Collectible offer count history16 RATING: The product's rating history. A rating is aninteger from 0 to 50 (e.g. 45 = 4.5 stars)17 COUNT_REVIEWS: The product's review count history.18 BUY_BOX_SHIPPING: The price history of the buy box. If nooffer qualified for the buy box the price has the value-1. Including shipping costs.19 USED_NEW_SHIPPING: "Used - Like New" price historyincluding shipping costs.20 USED_VERY_GOOD_SHIPPING: "Used - Very Good" price historyincluding shipping costs.21 USED_GOOD_SHIPPING: "Used - Good" price history includingshipping costs.22 USED_ACCEPTABLE_SHIPPING: "Used - Acceptable" price historyincluding shipping costs.23 COLLECTIBLE_NEW_SHIPPING: "Collectible - Like New" pricehistory including shipping costs.24 COLLECTIBLE_VERY_GOOD_SHIPPING: "Collectible - Very Good"price history including shipping costs.25 COLLECTIBLE_GOOD_SHIPPING: "Collectible - Good" pricehistory including shipping costs.26 COLLECTIBLE_ACCEPTABLE_SHIPPING: "Collectible - Acceptable"price history including shipping costs.27 REFURBISHED_SHIPPING: Refurbished price history includingshipping costs.30 TRADE_IN: The trade in price history. Amazon trade-in isnot available for every locale.31 RENT: Rental price history. Requires use of the rental and offers parameter. Amazon Rental is only availablefor Amazon US.Notes-----Negative prices"""# https://github.com/keepacom/api_backend# see api_backend/src/main/java/com/keepa/api/backend/structs/Product.java# [index in csv, key name, isfloat (is price)]indices = [[0, 'AMAZON', True],[1, 'NEW', True],[2, 'USED', True],[3, 'SALES', False],[4, 'LISTPRICE', True],[5, 'COLLECTIBLE', True],[6, 'REFURBISHED', True],[7, 'NEW_FBM_SHIPPING', True],[8, 'LIGHTNING_DEAL', True],[9, 'WAREHOUSE', True],[10, 'NEW_FBA', True],[11, 'COUNT_NEW', False],[12, 'COUNT_USED', False],[13, 'COUNT_REFURBISHED', False],[14, 'CollectableOffers', False],[15, 'EXTRA_INFO_UPDATES', False],[16, 'RATING', True],[17, 'COUNT_REVIEWS', False],[18, 'BUY_BOX_SHIPPING', True],[19, 'USED_NEW_SHIPPING', True],[20, 'USED_VERY_GOOD_SHIPPING', True],[21, 'USED_GOOD_SHIPPING', True],[22, 'USED_ACCEPTABLE_SHIPPING', True],[23, 'COLLECTIBLE_NEW_SHIPPING', True],[24, 'COLLECTIBLE_VERY_GOOD_SHIPPING', True],[25, 'COLLECTIBLE_GOOD_SHIPPING', True],[26, 'COLLECTIBLE_ACCEPTABLE_SHIPPING', True],[27, 'REFURBISHED_SHIPPING', True],[28, 'EBAY_NEW_SHIPPING', True],[29, 'EBAY_USED_SHIPPING', True],[30, 'TRADE_IN', True],[31, 'RENT', False]]product_data = {}for ind, key, isfloat in indices:if csv[ind]:  # Check if entry it existsif 'SHIPPING' in key:  # shipping price is included# Data goes [time0, value0, shipping0, time1, value1,#            shipping1, ...]times = csv[ind][::3]values = np.array(csv[ind][1::3])values += np.array(csv[ind][2::3])else:# Data goes [time0, value0, time1, value1, ...]times = csv[ind][::2]values = np.array(csv[ind][1::2])# Convert to float price if applicableif isfloat:nan_mask = values < 0values = values.astype(np.float)/100if out_of_stock_as_nan:values[nan_mask] = np.nanif key == 'RATING':values /= 10timeval = keepa_minutes_to_time(times, to_datetime)product_data['%s_time' % key] = timevalproduct_data[key] = valuesreturn product_data

这里有个细节,作者在解析时间,这里的时间大家不要将其作为时间戳来解析。解析函数我po上来了。他这个时间是在’2011-01-01’的基础上加的。



6.那排名是哪个键的值呢,别急,既然知道了作者给我们做了那么多的事,既然画图里面有用到排名的数据,又知道画图用的是product[‘data’]的值,还有这里的key的名称也是对应的。作者很贴心的。使用api的好处就是数据很干净。


7.那我们画一下这个图,对比对比。这里我画的图比较丑。

import matplotlib.pyplot as plt
plt.style.use('ggplot')# 设置绘图风格
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
# 设置图框的大小
fig = plt.figure(figsize=(20,6))
# 绘图
plt.plot(plot_data['SALES_time'], # x轴数据plot_data['SALES'], # y轴数据linestyle = '-', # 折线类型linewidth = 2, # 折线宽度color = 'steelblue', # 折线颜色marker = 'o', # 点的形状markersize = 6, # 点的大小markeredgecolor='black', # 点的边框色markerfacecolor='brown') # 点的填充色
# 添加标题和坐标轴标签
plt.title(product['title'])
plt.xlabel('Date')
plt.ylabel('Sales Rank')
# 剔除图框上边界和右边界的刻度
plt.tick_params(top = 'off', right = 'off')
# 为了避免x轴日期刻度标签的重叠,设置x轴刻度自动展现,并且45度倾斜
fig.autofmt_xdate(rotation = 45)
# 显示图形
plt.show()

还是比较相似的。

后面我肯定打算用pyecharts来作图的。
pyecharts代码合集。1.7.1版本的。

https://pyecharts.org/#/zh-cn/web_flask  flask-pyecharts
https://www.kesci.com/home/project/5d371e2fcf76a60036fecc97  案例 pyecharts 和鲸社区
https://www.jianshu.com/p/065b1676a0ca
https://github.com/awsekfozc?tab=stars
https://pyecharts.herokuapp.com/ pyecharts官网。
http://gallery.pyecharts.org/#/README pyecharts的示例代码

8.下面我们来解读一下keepa的数据,
frequentlyBoughtTogether =这个含义是顾客习惯这两个ASIN的一起买的,我比较看重的指标
features =是5点描述

catId =类目树(bestselller中有)的id,和类目名称

我还比较关心的是上架时间,这样可以看出他是不是新品。
这个产品的上架时间为2010/7/26
既然知道了是用keepa_minutes_to_time() 这个函数解析的。

那么将这个函数导入,使用即可。输出的结果与亚马逊上的一致。

from keepa import interface
listed_date =interface.keepa_minutes_to_time(product['listedSince'])
print(listed_date)

调用亚马逊插件keepa数据的API获取产品的历史信息相关推荐

  1. python根据频率画出词云_利用pandas+python制作100G亚马逊用户评论数据词云

    原标题:利用pandas+python制作100G亚马逊用户评论数据词云 数据挖掘入门与实战 公众号: datadw 我们手里面有一个差不多100G的亚马逊用户在购买商品后留下的评论数据(数据格式为j ...

  2. 对接亚马逊 SP-API(Amazon Selling Partner API) 第四章:签名

    目录 1. 前提概要 2. Authorization 介绍 Python 版本完整案例 3. 拼接 Authorization Task 1: Create a canonical request ...

  3. 亚马逊广告接口 amazon advert api 申请流程

    #亚马逊广告接口 amazon advert api 申请流程 官方文档 https://advertising.amazon.com/API/docs/en-us 申请连接 : https://ad ...

  4. 对接亚马逊 SP-API(Amazon Selling Partner API) 第一章:注册帐号

    目录 1. SP-API 基本介绍 1.1. 从 MWS 迁移到 SP-API 1.2. SP-API 开发者指南 1.3. MWS 与 SP-API 接口映射 1.4. SP-API 的站点 2. ...

  5. 对接亚马逊 SP-API(Amazon Selling Partner API) 第二章:授权

    目录 1. 授权销售伙伴 API 应用程序 1.1. Marketplace Appstore workflow 1.2. Website workflow(推荐使用) 1.3. 自行授权(仅限店铺本 ...

  6. 亚马逊美国站为什么要严查儿童产品  2021-04-02

    亚马逊美国站严查儿童产品          美国CPSC改革 新一轮严打开始了 CPSC从3月22号开始升级成为PGA参与政府机构! 图片 新一轮严打开始了!近日大量亚马逊卖家收到美国CPSC严查儿童 ...

  7. 亚马逊跨境电商如何编辑产品详情页 亚马逊产品listing优化

    产品详情页是买家了解产品的重要途径.也是影响产品转化率的重要因素.今天海熹跨境人才网给大家分享一下关于亚马逊跨境电商产品详情页的优化,亚马逊产品listing优化.一起来了解一下吧. 1:售前关联营销 ...

  8. 对接亚马逊 SP-API(Amazon Selling Partner API) 第三章:对接 SDK

    目录 必要条件 1. Generating a Java SDK with LWA token exchange and authentication 1.8. SwaggerToCL 结构. 1.9 ...

  9. 亚马逊瞄准大数据 欲在汽车行业抢占一席之地

    Amazon Vehicle各类车型的覆盖范围十分庞大,汽车爱好者甚至可以查阅到1965款福特野马的具体信息. 近日,亚马逊为汽车发烧友们推出了一个汽车专享页面--Amazon Vehicles.从敞 ...

最新文章

  1. 基于python的快速傅里叶变换FFT(一)
  2. HDU 1412 {A} + {B}
  3. PCL、XPS转换成PDF的控件activePDF Meridian​
  4. hello word 程序 ——简单的spring ioc 学习
  5. vuecli3修改html,详解vue-cli3多页应用改造
  6. Spring Boot 应用监控:Actuator与 Admin
  7. javascript中的异常处理
  8. Oracle数据库应用系统结构
  9. DaDa英语宣布12月31日起全面停止所有外教服务
  10. weblogic 10 及以后版本需要单独生成Weblogic10.3客户端jar文件
  11. MODBUS ASCII协议和RTU协议的比较 -----和利时PLC采用Modbus RTU
  12. 网易开源分布式存储系统 Curve,性能彪悍!这是要吊打阿里?
  13. Houdini学习笔记
  14. 使用Electron和Microsoft Bot Framework制作Skype Bot
  15. windows笔记本查看电池损耗
  16. 论文阅读——基于语法语义融合学习的功能代码克隆检测
  17. 发json请求,报415错误。POST http://localhost:8080/ 415
  18. 如何使用memset函数
  19. Vscode设置用户代码片段
  20. 基于eNSP的小型企业网(附ensp源文件)

热门文章

  1. ECharts合并地图上的区域(济南市合并莱芜市)
  2. windows中常用的一个轻量的扫描软件xray_windows_amd64
  3. Dynamics 365: 详解插件的执行深度(PluginExecutionContext.Depth)
  4. 孤独的7 虫蚀算-穷举法
  5. Ubuntu下使用valet搭建laravel生产环境
  6. Flash 与数学 星形线
  7. android 部分韩国手机采用KSC5601编码保存联系人,MTK平台手机无法显示联系人姓名
  8. 深度学习:卷积神经网络CNN入门
  9. VMware网络连接模式
  10. 服务计算(3)——开发简单CLI程序(selpg)