Subversion Repositories SmartDukaan

Rev

Rev 14811 | Rev 16283 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14811 amit.gupta 1
'''
2
Created on Apr 12, 2015
3
 
4
@author: amit
5
'''
6
from bs4 import BeautifulSoup
7
from dtr import main
8
from dtr.main import getBrowserObject, getStore, ParseException, ungzipResponse, \
9
    Store as MStore, sourceMap, tprint
10
from dtr.utils.utils import fetchResponseUsingProxy
11
from pymongo.mongo_client import MongoClient
12
 
13
class Store(MStore):
14
    OrderStatusMap = {
14848 amit.gupta 15
                      main.Store.ORDER_PLACED : [],
16
                      main.Store.ORDER_DELIVERED : [],
17
                      main.Store.ORDER_SHIPPED : ['in transit'],
18
                      main.Store.ORDER_CANCELLED : []
14811 amit.gupta 19
 
20
                      }
21
    def __init__(self,store_id):
22
        client = MongoClient('mongodb://localhost:27017/')
23
        self.db = client.dtr
24
        super(Store, self).__init__(store_id)
25
 
26
    def saveOrder(self, merchantOrder):
27
        MStore.saveOrder(self, merchantOrder)
28
 
29
    def scrapeStoreOrders(self):
30
        url = 'https://track.paytm.com/v1/track/order?ff_id=764691577&shipperId=32&awbNo=57983795671'
31
        page = fetchResponseUsingProxy(url)
32
        soup = BeautifulSoup(page)
33
        print "PayTM------------", soup.h1.text 
34
 
35
 
36
def main():
37
    store = getStore(6)
38
    store.scrapeStoreOrders()
39
 
40
if __name__ == '__main__':
41
    main()