| Line 461... |
Line 461... |
| 461 |
collectionMap = {'merchantOrderId':1}
|
461 |
collectionMap = {'merchantOrderId':1}
|
| 462 |
activeOrders = self._getActiveOrders(searchMap, collectionMap)
|
462 |
activeOrders = self._getActiveOrders(searchMap, collectionMap)
|
| 463 |
datetimeNow = datetime.now()
|
463 |
datetimeNow = datetime.now()
|
| 464 |
timestamp = int(time.mktime(datetimeNow.timetuple()))
|
464 |
timestamp = int(time.mktime(datetimeNow.timetuple()))
|
| 465 |
print "url----------------", url
|
465 |
print "url----------------", url
|
| 466 |
|
466 |
cancelledSummary = False
|
| 467 |
if url == 'https://www.amazon.in/gp/css/order-history' or 'https://www.amazon.in/gp/css/order-history/?orderFilter=cancelled' in url:
|
467 |
if url == 'https://www.amazon.in/gp/css/order-history' or 'https://www.amazon.in/gp/css/order-history/?orderFilter=cancelled' in url:
|
| 468 |
if url == 'https://www.amazon.in/gp/css/order-history':
|
468 |
if url == 'https://www.amazon.in/gp/css/order-history':
|
| 469 |
filename = directory + "/orderSummary" + datetime.strftime(datetime.now(), '%d-%m:%H:%M:%S')
|
469 |
filename = directory + "/orderSummary" + datetime.strftime(datetime.now(), '%d-%m:%H:%M:%S')
|
| 470 |
else:
|
470 |
else:
|
| 471 |
filename = directory + "/cancelledSummary" + datetime.strftime(datetime.now(), '%d-%m:%H:%M:%S')
|
471 |
filename = directory + "/cancelledSummary" + datetime.strftime(datetime.now(), '%d-%m:%H:%M:%S')
|
| - |
|
472 |
cancelledSummary = True
|
| 472 |
f = open(filename,'w')
|
473 |
f = open(filename,'w')
|
| 473 |
f.write(rawHtml) # python will convert \n to os.linesep
|
474 |
f.write(rawHtml) # python will convert \n to os.linesep
|
| 474 |
f.close() # you can omit in most cases as the destructor will call if
|
475 |
f.close() # you can omit in most cases as the destructor will call if
|
| 475 |
soup = BeautifulSoup(rawHtml)
|
476 |
soup = BeautifulSoup(rawHtml)
|
| 476 |
allOrders = soup.find(id="ordersContainer").findAll('div', {'class':'a-box-group a-spacing-base order'})
|
477 |
allOrders = soup.find(id="ordersContainer").findAll('div', {'class':'a-box-group a-spacing-base order'})
|
| Line 484... |
Line 485... |
| 484 |
orderdiv = orderEle.find('div', {'class':'a-box a-color-offset-background order-info'}).find('div', {'class':'a-fixed-right-grid-col actions a-col-right'})
|
485 |
orderdiv = orderEle.find('div', {'class':'a-box a-color-offset-background order-info'}).find('div', {'class':'a-fixed-right-grid-col actions a-col-right'})
|
| 485 |
merchantOrderId = orderdiv.find('span', {'class':'a-color-secondary value'}).text.strip()
|
486 |
merchantOrderId = orderdiv.find('span', {'class':'a-color-secondary value'}).text.strip()
|
| 486 |
if merchantOrderId==activeOrder['merchantOrderId']:
|
487 |
if merchantOrderId==activeOrder['merchantOrderId']:
|
| 487 |
matched=True
|
488 |
matched=True
|
| 488 |
closed = True
|
489 |
closed = True
|
| - |
|
490 |
if not cancelledSummary:
|
| 489 |
shipments = orderEle.findAll('div',{'class':re.compile('.*?shipment.*?')}, recursive=False)
|
491 |
shipments = orderEle.findAll('div',{'class':re.compile('.*?shipment.*?')}, recursive=False)
|
| - |
|
492 |
else:
|
| - |
|
493 |
shipments = orderEle.findAll('div',{'class':re.compile('.*?a-box.*?')}, recursive=False)
|
| - |
|
494 |
shipments.pop(0)
|
| 490 |
for shipment in shipments:
|
495 |
for shipment in shipments:
|
| 491 |
orderStatusDesc = None
|
496 |
orderStatusDesc = None
|
| 492 |
shipdiv = shipment.find('div', {'class':'a-box-inner'})
|
497 |
shipdiv = shipment.find('div', {'class':'a-box-inner'})
|
| 493 |
sdivs = shipment.div.div.findAll('div', recursive=False)
|
498 |
sdivs = shipment.div.div.findAll('div', recursive=False)
|
| 494 |
try:
|
499 |
try:
|
| Line 740... |
Line 745... |
| 740 |
|
745 |
|
| 741 |
|
746 |
|
| 742 |
|
747 |
|
| 743 |
def main():
|
748 |
def main():
|
| 744 |
store = getStore(1)
|
749 |
store = getStore(1)
|
| 745 |
for order in store.db.merchantOrder.find({"orderId":{"$gt":47644}, "storeId":3}):
|
750 |
# for order in store.db.merchantOrder.find({"orderId":{"$gt":47644}, "storeId":3}):
|
| 746 |
try:
|
751 |
# try:
|
| 747 |
orderId=order.get("orderId")
|
752 |
# orderId=order.get("orderId")
|
| 748 |
o = session.query(OrdersRaw).filter_by(id = orderId).one()
|
753 |
# o = session.query(OrdersRaw).filter_by(id = orderId).one()
|
| 749 |
o.status = 'ORDER_CREATED'
|
754 |
# o.status = 'ORDER_CREATED'
|
| 750 |
session.commit()
|
755 |
# session.commit()
|
| 751 |
finally:
|
756 |
# finally:
|
| 752 |
session.close()
|
757 |
# session.close()
|
| 753 |
#store.trackOrdersForUser(8703, 'https://www.amazon.in/gp/css/order-history', readSSh('/home/amit/Downloads/orderSummary06-10_12_15_54'))
|
758 |
store.trackOrdersForUser(2, 'https://www.amazon.in/gp/css/order-history/?orderFilter=cancelled', readSSh('/AmazonTrack/User2/cancelledSummary13-11:11:25:56'))
|
| 754 |
|
759 |
|
| 755 |
def getSummaryFile(directory):
|
760 |
def getSummaryFile(directory):
|
| 756 |
date1 = datetime(2015,1,1)
|
761 |
date1 = datetime(2015,1,1)
|
| 757 |
finalFile = None
|
762 |
finalFile = None
|
| 758 |
try:
|
763 |
try:
|