-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamazon_search.py
More file actions
42 lines (32 loc) · 1.05 KB
/
amazon_search.py
File metadata and controls
42 lines (32 loc) · 1.05 KB
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
from amazon.api import AmazonAPI # https://pypi.python.org/pypi/python-amazon-simple-product-api
import configparser
# config variables
config = configparser.ConfigParser()
config.read('config.ini')
# setup keywords/ search queries
keywords = []
kfile = open('./keywords.data', 'r')
for line in kfile:
keywords.append(line)
#print("Error reading keywords.data file")
print(keywords)
# setup brands
brands = []
bfile = open('./brands.data', 'r')
for line in bfile:
brands.append(line)
print(brands)
# setup AMAZON API
amazon = AmazonAPI(config['API']['AMAZON_ACCESS_KEY'], config['API']['AMAZON_SECRET_KEY'], config['API']['AMAZON_ASSOC_TAG'])
# run amazon product search
products = amazon.search(Keywords='Diapers', SearchIndex=config['LOCALE']['REGION'])
hcount = 0
pcount = 0
for i, product in enumerate(products):
if 'huggies' in product.title.lower():
hcount += 1
if 'pampers' in product.title.lower():
pcount += 1
print(str(i) + ": " + product.title)
print(" -- Huggies found :" + str(hcount))
print(" -- Pampers found :" + str(pcount))