| Line 93... |
Line 93... |
| 93 |
traceback.print_exc()
|
93 |
traceback.print_exc()
|
| 94 |
self.parseCancelled(merchantOrder, soup)
|
94 |
self.parseCancelled(merchantOrder, soup)
|
| 95 |
resp['result'] = 'ORDER_CREATED'
|
95 |
resp['result'] = 'ORDER_CREATED'
|
| 96 |
return resp
|
96 |
return resp
|
| 97 |
except:
|
97 |
except:
|
| - |
|
98 |
try:
|
| - |
|
99 |
self.parserest(soup)
|
| - |
|
100 |
resp['result'] = 'PARSED_ORDER_NOT_CREATED'
|
| - |
|
101 |
return resp
|
| - |
|
102 |
except:
|
| 98 |
order = self.db.merchantOrder.find_one({"orderId":orderId})
|
103 |
order = self.db.merchantOrder.find_one({"orderId":orderId})
|
| 99 |
if order is not None:
|
104 |
if order is not None:
|
| 100 |
self.db.merchantOrder.update({"orderId":orderId}, {"$set":{"status":"parse_failed"}})
|
105 |
self.db.merchantOrder.update({"orderId":orderId}, {"$set":{"status":"parse_failed"}})
|
| 101 |
print "Error occurred"
|
106 |
print "Error occurred"
|
| 102 |
traceback.print_exc()
|
107 |
resp['result'] = 'ORDER_NOT_CREATED'
|
| 103 |
resp['result'] = 'ORDER_NOT_CREATED'
|
108 |
traceback.print_exc()
|
| 104 |
return resp
|
109 |
return resp
|
| 105 |
|
110 |
|
| 106 |
#This should be exposed from api for specific sources
|
111 |
#This should be exposed from api for specific sources
|
| 107 |
def scrapeStoreOrders(self):
|
112 |
def scrapeStoreOrders(self):
|
| 108 |
orders = self.db.merchantOrder.find({"storeId":1, "closed":False, "subOrders.closed":False, "subOrders.trackingUrl":{"$exists":True}})
|
113 |
orders = self.db.merchantOrder.find({"storeId":1, "closed":False, "subOrders.closed":False, "subOrders.trackingUrl":{"$exists":True}})
|
| 109 |
for merchantOrder in orders:
|
114 |
for merchantOrder in orders:
|
| Line 135... |
Line 140... |
| 135 |
self.db.merchantOrder.update({"orderId":merchantOrder['orderId']}, {"$set":{"parseError":True}})
|
140 |
self.db.merchantOrder.update({"orderId":merchantOrder['orderId']}, {"$set":{"parseError":True}})
|
| 136 |
traceback.print_exc()
|
141 |
traceback.print_exc()
|
| 137 |
|
142 |
|
| 138 |
|
143 |
|
| 139 |
|
144 |
|
| - |
|
145 |
def parserest(self, soup):
|
| - |
|
146 |
print "Hi"
|
| - |
|
147 |
if soup.find('h1'):
|
| - |
|
148 |
print "OK"
|
| 140 |
|
149 |
|
| 141 |
def parseOldStlye(self, merchantOrder, soup):
|
150 |
def parseOldStlye(self, merchantOrder, soup):
|
| 142 |
merchantOrder.orderTrackingUrl = merchantOrder.orderSuccessUrl
|
151 |
merchantOrder.orderTrackingUrl = merchantOrder.orderSuccessUrl
|
| 143 |
table = soup.body.findAll("table", recursive=False)[1]
|
152 |
table = soup.body.findAll("table", recursive=False)[1]
|
| 144 |
#print table
|
153 |
#print table
|
| Line 515... |
Line 524... |
| 515 |
# ('Accept', 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8'),
|
524 |
# ('Accept', 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8'),
|
| 516 |
# ('Accept-Encoding', 'gzip,deflate,sdch'),
|
525 |
# ('Accept-Encoding', 'gzip,deflate,sdch'),
|
| 517 |
# ('Accept-Language', 'en-US,en;q=0.8'),
|
526 |
# ('Accept-Language', 'en-US,en;q=0.8'),
|
| 518 |
# ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')]
|
527 |
# ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')]
|
| 519 |
# store.scrapeStoreOrders()
|
528 |
# store.scrapeStoreOrders()
|
| 520 |
store.parseOrderRawHtml(1306, "13232", 14, readSSh("/home/amit/322.html"), "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-5857029-0804336")
|
529 |
store.parseOrderRawHtml(1306, "13232", 14, readSSh("/home/amit/322.html"), "https://www.amazon.in/gp/buy/thankyou/handlers/display.html?ie=UTF8&from=Visa&fromAnywhere=1&isFromThirdParty=1&purchaseId=404-602")
|
| 521 |
#store.parseOrderRawHtml(2121, "13232", 14, readSSh("/home/amit/f1.html"), "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-5196461-3230730")
|
530 |
#store.parseOrderRawHtml(2121, "13232", 14, readSSh("/home/amit/f1.html"), "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-5196461-3230730")
|
| 522 |
#readSSh("/tmp/User211/2015-04-01 15:31:42.250309")
|
531 |
#readSSh("/tmp/User211/2015-04-01 15:31:42.250309")
|
| 523 |
#store.scrapeAffiliate()
|
532 |
#store.scrapeAffiliate()
|
| 524 |
def readSSh(fileName):
|
533 |
def readSSh(fileName):
|
| 525 |
try:
|
534 |
try:
|