Subversion Repositories SmartDukaan

Rev

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

Rev 13610 Rev 13631
Line 4... Line 4...
4
@author: amit
4
@author: amit
5
'''
5
'''
6
from pymongo.mongo_client import MongoClient
6
from pymongo.mongo_client import MongoClient
7
import importlib
7
import importlib
8
import mechanize
8
import mechanize
-
 
9
import traceback
9
sourceMap = {1:"amazon", 2:"flipkart", 3:"snapdeal", 4:"spice", 5:"homeshop18"}
10
sourceMap = {1:"amazon", 2:"flipkart", 3:"snapdeal", 4:"spice", 5:"homeshop18"}
10
 
11
 
11
 
12
 
12
def getStore(source_id):
13
def getStore(source_id):
13
    #module = sourceMap[source_id]
14
    #module = sourceMap[source_id]
14
    store = Store(source_id)
15
    store = Store(source_id)
-
 
16
    try:
15
    module = importlib.import_module("dtr.sources." + sourceMap[source_id])
17
        module = importlib.import_module("dtr.sources." + sourceMap[source_id])
16
    store = getattr(module, "Store")(source_id)
18
        store = getattr(module, "Store")(source_id)
17
    return store
19
        return store
-
 
20
    except:
-
 
21
        traceback.print_exc()
-
 
22
        return None
18
 
23
 
19
class ScrapeException(Exception):
24
class ScrapeException(Exception):
20
    """Exception raised for errors in the input.
25
    """Exception raised for errors in the input.
21
 
26
 
22
    Attributes:
27
    Attributes: