| Line 93... |
Line 93... |
| 93 |
if soup.h2.text.strip() == 'Web page not available':
|
93 |
if soup.h2.text.strip() == 'Web page not available':
|
| 94 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
94 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
| 95 |
else:
|
95 |
else:
|
| 96 |
raise
|
96 |
raise
|
| 97 |
except:
|
97 |
except:
|
| - |
|
98 |
try:
|
| - |
|
99 |
if soup.find(id="loading-spinner-img") is not None:
|
| - |
|
100 |
resp['result'] = 'ORDER_NOT_CREATED_KNOWN'
|
| - |
|
101 |
else:
|
| - |
|
102 |
raise
|
| - |
|
103 |
except:
|
| 98 |
resp['result'] = 'ORDER_NOT_CREATED_UNKNOWN'
|
104 |
resp['result'] = 'ORDER_NOT_CREATED_UNKNOWN'
|
| - |
|
105 |
|
| 99 |
else:
|
106 |
else:
|
| 100 |
try:
|
107 |
try:
|
| 101 |
mo = self.db.merchantOrder.find_one({"orderId":orderId})
|
108 |
mo = self.db.merchantOrder.find_one({"orderId":orderId})
|
| 102 |
if mo is not None:
|
109 |
if mo is not None:
|
| 103 |
merchantOrder = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl, False)
|
110 |
merchantOrder = Order(orderId, userId, subTagId, self.store_id, orderSuccessUrl, False)
|
| Line 601... |
Line 608... |
| 601 |
|
608 |
|
| 602 |
def main():
|
609 |
def main():
|
| 603 |
#str1 = readSSh("/AmazonTrack/User533/403-3748792-1516356")
|
610 |
#str1 = readSSh("/AmazonTrack/User533/403-3748792-1516356")
|
| 604 |
#readSSh("/tmp/User2/404-2225153-7073122")
|
611 |
#readSSh("/tmp/User2/404-2225153-7073122")
|
| 605 |
|
612 |
|
| 606 |
#store = getStore(1)
|
613 |
store = getStore(1)
|
| 607 |
#store.scrapeStoreOrders()
|
614 |
#store.scrapeStoreOrders()
|
| 608 |
# br = mechanize.Browser()
|
615 |
# br = mechanize.Browser()
|
| 609 |
# br.addheaders = [('User-agent','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11'),
|
616 |
# br.addheaders = [('User-agent','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11'),
|
| 610 |
# ('Accept', 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8'),
|
617 |
# ('Accept', 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8'),
|
| 611 |
# ('Accept-Encoding', 'gzip,deflate,sdch'),
|
618 |
# ('Accept-Encoding', 'gzip,deflate,sdch'),
|
| 612 |
# ('Accept-Language', 'en-US,en;q=0.8'),
|
619 |
# ('Accept-Language', 'en-US,en;q=0.8'),
|
| 613 |
# ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')]
|
620 |
# ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')]
|
| 614 |
# store.scrapeStoreOrders()
|
621 |
# store.scrapeStoreOrders()
|
| 615 |
#store.parseOrderRawHtml(3418, "13232", 14, readSSh("/home/amit/3418"), "https://www.amazon.in/gp/css/summary/edit.html?orderID=402-1853822-0778736")
|
622 |
store.parseOrderRawHtml(5322, "13232", 14, readSSh("/home/amit/5322"), "https://www.amazon.in/gp/buy/spc/handlers/static-submit-decoupled.html/ref=ox_spc_place_order?ie=UTF8&fromAnywhere=1&hasWorkingJav")
|
| 616 |
#store.trackOrdersForUser(4355, "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-4824011-7090713", readSSh("~/4355"))
|
623 |
#store.trackOrdersForUser(4355, "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-4824011-7090713", readSSh("~/4355"))
|
| 617 |
#readSSh("/tmp/User211/2015-04-12 10:32:41.905765")
|
624 |
#readSSh("/tmp/User211/2015-04-12 10:32:41.905765")
|
| 618 |
#store.scrapeAffiliate()
|
625 |
#store.scrapeAffiliate()
|
| 619 |
parseDetailNotCreated()
|
626 |
#parseDetailNotCreated()
|
| - |
|
627 |
parseOrderNotCreated()
|
| 620 |
|
628 |
|
| 621 |
def parseDetailNotCreated():
|
629 |
def parseDetailNotCreated():
|
| 622 |
try:
|
630 |
try:
|
| 623 |
store=getStore(1)
|
631 |
store=getStore(1)
|
| 624 |
orders = session.query(OrdersRaw).filter_by(status='DETAIL_NOT_CREATED_UNKNOWN').all()
|
632 |
orders = session.query(OrdersRaw).filter_by(status='DETAIL_NOT_CREATED_UNKNOWN').all()
|
| Line 626... |
Line 634... |
| 626 |
for order in orders:
|
634 |
for order in orders:
|
| 627 |
store.trackOrdersForUser(order.id, order.order_url, order.rawhtml)
|
635 |
store.trackOrdersForUser(order.id, order.order_url, order.rawhtml)
|
| 628 |
|
636 |
|
| 629 |
finally:
|
637 |
finally:
|
| 630 |
session.close()
|
638 |
session.close()
|
| - |
|
639 |
|
| - |
|
640 |
def parseOrderNotCreated():
|
| - |
|
641 |
try:
|
| - |
|
642 |
store=getStore(1)
|
| - |
|
643 |
orders = session.query(OrdersRaw).filter_by(status='ORDER_NOT_CREATED_UNKNOWN').all()
|
| - |
|
644 |
session.close()
|
| - |
|
645 |
for order in orders:
|
| - |
|
646 |
store.parseOrderRawHtml(order.id, order.sub_tag, order.user_id, order.rawhtml, order.order_url)
|
| - |
|
647 |
|
| - |
|
648 |
finally:
|
| - |
|
649 |
session.close()
|
| 631 |
|
650 |
|
| 632 |
def readSSh(fileName):
|
651 |
def readSSh(fileName):
|
| 633 |
try:
|
652 |
try:
|
| 634 |
str1 = open(fileName).read()
|
653 |
str1 = open(fileName).read()
|
| 635 |
return str1
|
654 |
return str1
|