1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import keepa
key = 'engpg35aootqo11korrc9p4otp0p1il5a5ssnjvdq5ehfnh6us8hb1klobq61c9t'
api = keepa.Keepa(key)
# print(dir(api))
for d in dir(api):
print(d)
# categories = api.search_for_categories("movies")
# print(categories)
# categories = api.search_for_categories('Tabletop & Serveware')
categories = api.search_for_categories('spoons')
print(len(categories.keys()), list(categories.keys()))
for cat_id in categories:
print(cat_id, categories[cat_id]['name'])
# quit()
product_parms = {
# 'author': 'jim butcher',
'sort': ["current_SALES", "asc"],
'current_SALES_gte': 500,
'current_SALES_lte': 510,
'categories_include': [498924]
}
product_parms = {
"current_SALES_gte": 500,
"current_SALES_lte": 50000,
"rootCategory": 1055398, # 一级分类id
'categories_include': list(categories.keys()),
"current_AMAZON_gte": 1998, # 亚马逊当前价格 -- 1998>=19.98
"current_AMAZON_lte": 1998, # 亚马逊当前价格 -- 1998<=19.98
"sort": [
[
"current_SALES",
"asc"
]
],
"productType": [
0,
1
],
"perPage": 50,
"page": 0,
# 'categories_include': [3206325011]
}
product_parms = {
# "title": "spoons",
"current_AMAZON_gte": 1,
"current_AMAZON_lte": 3000,
# "current_SALES_gte": 100,
# "current_SALES_lte": 1000,
'delta30_SALES_gte': 100,
'delta30_SALES_lte': 500,
# "categories_include": [
# "289754"
# ],
"sort": [
[
"current_SALES",
"asc"
]
],
"productType": [
0,
1
],
"perPage": 500,
"page": 0
}
asins = api.product_finder(product_parms=product_parms)
print(len(asins), asins)
# quit()
class KeepApi(object):
def __init__(self):
self.key = 'engpg35aootqo11korrc9p4otp0p1il5a5ssnjvdq5ehfnh6us8hb1klobq61c9t'
self.api = keepa.Keepa(self.key)
def product_finder(self):
pass
def search_for_categories(self, searchterm=''):
# 关键词查找分类
return self.api.search_for_categories(
searchterm=searchterm,
domain='US',
wait=True
)
def category_lookup(self):
pass
def best_sellers_query(self):
# 返回asin_list
pass
if __name__ == '__main__':
# categories = api.search_for_categories("Home & Kitchen")
# categories = api.search_for_categories("coasters")
# print(type(categories), categories)
# print(list(categories.items())[0], categories)
# print(list(categories.items())[1], categories)
# category = list(categories.items())[0][0]
# asins = api.best_sellers_query(category)
# print(len(asins), asins)
# rank_avg_range参数无用,报错
# asins = api.best_sellers_query(category, rank_avg_range=100)
# print(len(asins), asins)
# api_obj = KeepApi()
# categories = api_obj.search_for_categories('science')
# print(type(categories), categories)
# for cat_id in categories:
# print(cat_id, categories[cat_id]['name'])
#
# for k, v in categories.items():
# print(k, v)
pass