-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstart.py
38 lines (34 loc) · 1.17 KB
/
start.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
34
35
36
37
38
from all_imports import *
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--purl', type=str, help='Add said id to database')
parser.add_argument(
'-w',
'--wurl',
type=str,
help='Add all items from wishlist to database.')
parser.add_argument(
'-s',
'--show',
help='Show all entries in db.',
action='store_true')
args = parser.parse_args()
if not ((args.purl is None) ^ (args.wurl is None)):
print 'Please input only product url or wishlist url.'
elif args.purl:
# args.purl = args.purl[:args.purl.rfind('/')] # uncommet if entering url of product
# args.purl = args.purl[args.purl.rfind('/') + 1:] # as above
product = Product(args.purl)
product.startTracking()
elif args.wurl:
# wl = Wishlist(args.wurl) # uncomeent if entering url of wishlist
wl = Wishlist('http://www.amazon.in/gp/registry/wishlist/' + args.wurl)
wl.trackAllinWL()
if args.show:
db = DB()
alltr = db.all(table='tracking')
if len(alltr) == 0:
print 'No items added yet.'
i = 0
for entry in alltr:
i = i + 1
print str(i) + ') ' + entry[1] + '\n\thttp://www.amazon.in/gp/product/' + entry[0]