| Line 10... |
Line 10... |
| 10 |
from dtr.dao import AffiliateInfo, Order, SubOrder, ShopCluesAffiliateInfo
|
10 |
from dtr.dao import AffiliateInfo, Order, SubOrder, ShopCluesAffiliateInfo
|
| 11 |
from dtr.main import getBrowserObject, ScrapeException, getStore, ParseException, \
|
11 |
from dtr.main import getBrowserObject, ScrapeException, getStore, ParseException, \
|
| 12 |
Store as MStore, ungzipResponse, tprint
|
12 |
Store as MStore, ungzipResponse, tprint
|
| 13 |
from dtr.storage import Mongo
|
13 |
from dtr.storage import Mongo
|
| 14 |
from dtr.storage.Mongo import getImgSrc
|
14 |
from dtr.storage.Mongo import getImgSrc
|
| 15 |
from dtr.utils.utils import fetchResponseUsingProxy
|
15 |
from dtr.utils.utils import fetchResponseUsingProxy, PROXY_MESH_GENERAL
|
| 16 |
from pprint import pprint
|
16 |
from pprint import pprint
|
| 17 |
from pymongo import MongoClient
|
17 |
from pymongo import MongoClient
|
| 18 |
import json
|
18 |
import json
|
| 19 |
import pymongo
|
19 |
import pymongo
|
| 20 |
import re
|
20 |
import re
|
| Line 25... |
Line 25... |
| 25 |
from urlparse import urlparse, parse_qs
|
25 |
from urlparse import urlparse, parse_qs
|
| 26 |
import xml.etree.ElementTree as ET
|
26 |
import xml.etree.ElementTree as ET
|
| 27 |
from dtr.storage import MemCache
|
27 |
from dtr.storage import MemCache
|
| 28 |
from dtr.storage.Mongo import getDealRank
|
28 |
from dtr.storage.Mongo import getDealRank
|
| 29 |
|
29 |
|
| 30 |
USERNAME='profittill2@gmail.com'
|
- |
|
| 31 |
PASSWORD='spice@2020'
|
- |
|
| 32 |
AFFLIATE_TRASACTIONS_URL = "https://admin.optimisemedia.com/v2/reports/affiliate/leads/leadsummaryexport.aspx?Contact=796881&Country=26&Agency=95&Merchant=420562&Status=-1&Year=%d&Month=%d&Day=%d&EndYear=%d&EndMonth=%d&EndDay=%d&DateType=0&Sort=CompletionDate&Login=1347562DA5E3EFF6FB1561765C47C782&Format=XML&RestrictURL=0"
|
30 |
AFFLIATE_TRASACTIONS_URL = "https://admin.optimisemedia.com/v2/reports/affiliate/leads/leadsummaryexport.aspx?Contact=796881&Country=26&Agency=95&Merchant=420562&Status=-1&Year=%d&Month=%d&Day=%d&EndYear=%d&EndMonth=%d&EndDay=%d&DateType=0&Sort=CompletionDate&Login=1347562DA5E3EFF6FB1561765C47C782&Format=XML&RestrictURL=0"
|
| 33 |
ORDER_TRACK_URL='http://www.shopclues.com/index.php?dispatch=order_lookup.details'
|
31 |
ORDER_TRACK_URL='http://www.shopclues.com/index.php?dispatch=order_lookup.details'
|
| 34 |
ORDER_TRACK_URL_DB='https://sm.shopclues.com/trackOrder?'
|
32 |
ORDER_TRACK_URL_DB='https://sm.shopclues.com/trackOrder?'
|
| 35 |
BASE_URL= 'http://www.shopclues.com'
|
33 |
BASE_URL= 'http://www.shopclues.com'
|
| 36 |
BASE_MURL= 'http://m.shopclues.com'
|
34 |
BASE_MURL= 'http://m.shopclues.com'
|
| Line 605... |
Line 603... |
| 605 |
subbulk = self.db.merchantOrder.initialize_ordered_bulk_op()
|
603 |
subbulk = self.db.merchantOrder.initialize_ordered_bulk_op()
|
| 606 |
print 'Sub Order Id', str(subOrderId)+'-'+str(count)
|
604 |
print 'Sub Order Id', str(subOrderId)+'-'+str(count)
|
| 607 |
subOrder = self._isSubOrderActive(order, str(subOrderId)+'-'+str(count))
|
605 |
subOrder = self._isSubOrderActive(order, str(subOrderId)+'-'+str(count))
|
| 608 |
if subOrder is None:
|
606 |
if subOrder is None:
|
| 609 |
try:
|
607 |
try:
|
| - |
|
608 |
print 'Email Id:- '+ str(order['orderTrackingUrl'].split('email_id=')[1])+' and Order Id:- ' + str(subOrderId)
|
| 610 |
subOrders = self.parseSingleSubOrder(soup, order['orderTrackingUrl'].split('email_id=')[1], subOrderId)
|
609 |
subOrders = self.parseSingleSubOrder(soup, order['orderTrackingUrl'].split('email_id=')[1], subOrderId)
|
| 611 |
for subOrder in subOrders:
|
610 |
for subOrder in subOrders:
|
| 612 |
if subOrder is None:
|
611 |
if subOrder is None:
|
| 613 |
continue
|
612 |
continue
|
| 614 |
self.db.merchantOrder.update({"orderId":order['orderId']},{'$push':{"subOrders":{"$each":todict([subOrder])}}})
|
613 |
self.db.merchantOrder.update({"orderId":order['orderId']},{'$push':{"subOrders":{"$each":todict([subOrder])}}})
|
| Line 746... |
Line 745... |
| 746 |
else:
|
745 |
else:
|
| 747 |
return obj
|
746 |
return obj
|
| 748 |
|
747 |
|
| 749 |
def login(url):
|
748 |
def login(url):
|
| 750 |
br = getBrowserObject()
|
749 |
br = getBrowserObject()
|
| 751 |
br.set_proxies({"http": "us-il.proxymesh.com:31280"})
|
750 |
br.set_proxies({"http": PROXY_MESH_GENERAL})
|
| 752 |
br.open(url)
|
751 |
br.open(url)
|
| 753 |
response = br.open(url)
|
752 |
response = br.open(url)
|
| 754 |
ungzipResponseBr(response, br)
|
753 |
ungzipResponseBr(response, br)
|
| 755 |
#html = response.read()
|
754 |
#html = response.read()
|
| 756 |
#print html
|
755 |
#print html
|