Subversion Repositories SmartDukaan

Rev

Rev 14057 | Rev 14379 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14057 Rev 14257
Line 3... Line 3...
3
from BeautifulSoup import BeautifulSoup
3
from BeautifulSoup import BeautifulSoup
4
import pymongo
4
import pymongo
5
import re
5
import re
6
from dtr.utils.utils import to_java_date
6
from dtr.utils.utils import to_java_date
7
from datetime import datetime
7
from datetime import datetime
-
 
8
import optparse
8
 
9
 
9
con = None
10
con = None
-
 
11
parser = optparse.OptionParser()
-
 
12
parser.add_option("-m", "--m", dest="mongoHost",
-
 
13
                      default="localhost",
-
 
14
                      type="string", help="The HOST where the mongo server is running",
-
 
15
                      metavar="mongo_host")
-
 
16
 
-
 
17
(options, args) = parser.parse_args()
-
 
18
 
10
bestSellers = []
19
bestSellers = []
11
now = datetime.now()
20
now = datetime.now()
12
mobUrl = "http://www.saholic.com/mobile-phone/10006"
21
mobUrl = "http://www.saholic.com/mobile-phone/10006"
13
tabUrl = "http://www.saholic.com/all-tablets/10010"
22
tabUrl = "http://www.saholic.com/all-tablets/10010"
14
 
23
 
Line 16... Line 25...
16
    
25
    
17
    def __init__(self, identifier, rank):
26
    def __init__(self, identifier, rank):
18
        self.identifier = identifier
27
        self.identifier = identifier
19
        self.rank  = rank
28
        self.rank  = rank
20
 
29
 
21
def get_mongo_connection(host='localhost', port=27017):
30
def get_mongo_connection(host=options.mongoHost, port=27017):
22
    global con
31
    global con
23
    if con is None:
32
    if con is None:
24
        print "Establishing connection %s host and port %d" %(host,port)
33
        print "Establishing connection %s host and port %d" %(host,port)
25
        try:
34
        try:
26
            con = pymongo.MongoClient(host, port)
35
            con = pymongo.MongoClient(host, port)