-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProductInfo.py
33 lines (26 loc) · 967 Bytes
/
ProductInfo.py
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
from elasticsearch import Elasticsearch
import elasticsearch.helpers
es = Elasticsearch(['http://es.backpackbang.com:9200/'])
def get(cat, asin):
try:
res = es.search(index="products", doc_type="amazon", body={"query": {"match": {"_id": asin}}})
res = res['hits']['hits']
if len(res) == 0 or cat not in res[0]['_source']:
return ""
else:
return res[0]['_source'][cat]
except Exception as e:
print(e)
return ""
if __name__ == "__main__":
# print(get("title", "B071GRBWG6"))
# print(get("title", "B00N2AY7WM"))
# print(get("title", "B07CY1X7YL"))
# print(get("title", "B06XFGTGC4"))
# print(get("title", "B07FQMBWQG"))
# print(get("title", "B078P2XN9M"))
# print(get("title", "B01LXTK4T6"))
# print(get("title", "B01D402Z28"))
# print(get("title", "B0711T4RDF"))
# print(get("title", "B0785MMPJ1"))
print(get("dimensions", "B06XCM9LJ4"))