| Line 10... |
Line 10... |
| 10 |
from dtr.api.Order import process_rejects
|
10 |
from dtr.api.Order import process_rejects
|
| 11 |
from dtr.dao import Order, SubOrder, AmazonAffiliateInfo
|
11 |
from dtr.dao import Order, SubOrder, AmazonAffiliateInfo
|
| 12 |
from dtr.main import getStore, Store as MStore, ParseException, getBrowserObject, \
|
12 |
from dtr.main import getStore, Store as MStore, ParseException, getBrowserObject, \
|
| 13 |
ungzipResponse, tprint
|
13 |
ungzipResponse, tprint
|
| 14 |
from dtr.sources.flipkart import todict, AFF_REPORT_URL
|
14 |
from dtr.sources.flipkart import todict, AFF_REPORT_URL
|
| 15 |
from dtr.storage.DataService import OrdersRaw
|
15 |
from dtr.storage.DataService import OrdersRaw, Orders, Order_Parse_Info
|
| 16 |
from dtr.storage.Mongo import getDealRank
|
16 |
from dtr.storage.Mongo import getDealRank
|
| 17 |
from dtr.utils.utils import fetchResponseUsingProxy, readSSh
|
17 |
from dtr.utils.utils import fetchResponseUsingProxy, readSSh
|
| 18 |
from elixir import *
|
18 |
from elixir import *
|
| 19 |
import base64
|
19 |
import base64
|
| 20 |
import dtr
|
20 |
import dtr
|
| Line 620... |
Line 620... |
| 620 |
|
620 |
|
| 621 |
return subOrder
|
621 |
return subOrder
|
| 622 |
|
622 |
|
| 623 |
|
623 |
|
| 624 |
|
624 |
|
| - |
|
625 |
def parseInfo(self,):
|
| - |
|
626 |
from pyquery import PyQuery as pq
|
| - |
|
627 |
orders = list(session.query(Orders).filter_by(store_id=self.store_id).filter_by(status='DETAIL_CREATED').all())
|
| 625 |
|
628 |
try:
|
| - |
|
629 |
for order in orders:
|
| - |
|
630 |
try:
|
| - |
|
631 |
doc = pq(order.rawhtml)
|
| - |
|
632 |
#a1= " ".join(["" if not div.text else div.text.replace("\t","").replace("\n","").replace(" ", "") for div in pq(doc('article')[-1])('div')])
|
| - |
|
633 |
lists = doc('ul.displayAddressUL li')
|
| - |
|
634 |
orderInfo = Order_Parse_Info()
|
| - |
|
635 |
orderInfo.address = lists[-3].text
|
| - |
|
636 |
orderInfo.user_id = order.user_id
|
| - |
|
637 |
orderInfo.order_id = order.id
|
| - |
|
638 |
orderInfo.email = None
|
| - |
|
639 |
orderInfo.name = lists[0].text
|
| - |
|
640 |
orderInfo.mobile = None
|
| - |
|
641 |
adSplit = lists[-2].text.split(",")
|
| - |
|
642 |
match = re.match(r"([a-z ]+)([0-9]+)", adSplit[1], re.I)
|
| - |
|
643 |
if match:
|
| - |
|
644 |
items = match.groups()
|
| - |
|
645 |
orderInfo.city = adSplit[0]
|
| - |
|
646 |
orderInfo.pin = items[1]
|
| - |
|
647 |
orderInfo.state = items[0].upper()
|
| - |
|
648 |
session.commit()
|
| - |
|
649 |
except:
|
| - |
|
650 |
session.rollback()
|
| - |
|
651 |
continue
|
| - |
|
652 |
finally:
|
| - |
|
653 |
session.close()
|
| 626 |
|
654 |
|
| 627 |
|
655 |
|
| 628 |
|
656 |
|
| 629 |
def main():
|
657 |
def main():
|
| 630 |
#process_rejects("/home/amit/Downloads/RejectCashbackTemplate.xlsx")
|
658 |
#process_rejects("/home/amit/Downloads/RejectCashbackTemplate.xlsx")
|
| Line 646... |
Line 674... |
| 646 |
# ('Accept', 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8'),
|
674 |
# ('Accept', 'text/html,application/xhtml+xml,application/json,application/xml;q=0.9,*/*;q=0.8'),
|
| 647 |
# ('Accept-Encoding', 'gzip,deflate,sdch'),
|
675 |
# ('Accept-Encoding', 'gzip,deflate,sdch'),
|
| 648 |
# ('Accept-Language', 'en-US,en;q=0.8'),
|
676 |
# ('Accept-Language', 'en-US,en;q=0.8'),
|
| 649 |
# ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')]
|
677 |
# ('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.3')]
|
| 650 |
# store.scrapeStoreOrders()
|
678 |
# store.scrapeStoreOrders()
|
| - |
|
679 |
store.parseInfo()
|
| 651 |
store.parseOrderRawHtml(9274, "13232", 14, readSSh("/home/amit/Downloads/9274.html"), "https://www.amazon.in/gp/buy/spc/handlers/static-submit-decoupled.html/ref=ox_spc_place_order?ie=UTF8&fromAnywhere=1&hasWorkingJav")
|
680 |
#store.parseOrderRawHtml(9274, "13232", 14, readSSh("/home/amit/Downloads/9274.html"), "https://www.amazon.in/gp/buy/spc/handlers/static-submit-decoupled.html/ref=ox_spc_place_order?ie=UTF8&fromAnywhere=1&hasWorkingJav")
|
| 652 |
#store.trackOrdersForUser(4355, "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-4824011-7090713", readSSh("~/4355"))
|
681 |
#store.trackOrdersForUser(4355, "https://www.amazon.in/gp/css/summary/edit.html?orderID=171-4824011-7090713", readSSh("~/4355"))
|
| 653 |
#readSSh("/tmp/User211/2015-04-12 10:32:41.905765")
|
682 |
#readSSh("/tmp/User211/2015-04-12 10:32:41.905765")
|
| 654 |
#store.scrapeAffiliate()
|
683 |
#store.scrapeAffiliate()
|
| 655 |
#parseDetailNotCreated()
|
684 |
#parseDetailNotCreated()
|
| 656 |
#parseOrderNotCreated()
|
685 |
#parseOrderNotCreated()
|