Subversion Repositories SmartDukaan

Rev

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

Rev 15497 Rev 15498
Line 13... Line 13...
13
 
13
 
14
config_client = ConfigClient()
14
config_client = ConfigClient()
15
host = config_client.get_property('staging_hostname')
15
host = config_client.get_property('staging_hostname')
16
DataService.initialize(db_hostname=host)
16
DataService.initialize(db_hostname=host)
17
 
17
 
-
 
18
headers = { 
-
 
19
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
-
 
20
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
-
 
21
            'Accept-Language' : 'en-US,en;q=0.8',                     
-
 
22
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
-
 
23
        }
-
 
24
 
18
class CompetitorScraping(Daemon):
25
class CompetitorScraping(Daemon):
19
    def __init__(self, logfile='/var/log/services/competitorScraping.log', pidfile='/var/run/competitor-scraper.pid'):
26
    def __init__(self, logfile='/var/log/services/competitorScraping.log', pidfile='/var/run/competitor-scraper.pid'):
20
        Daemon.__init__(self, pidfile, stdout=logfile, stderr=logfile)
27
        Daemon.__init__(self, pidfile, stdout=logfile, stderr=logfile)
21
        
28
        
22
    def run(self):
29
    def run(self):
Line 89... Line 96...
89
            continue
96
            continue
90
        try:
97
        try:
91
            url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=175&sort=sellingPrice"%(sdItem.supc)
98
            url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=175&sort=sellingPrice"%(sdItem.supc)
92
            print url
99
            print url
93
            time.sleep(1)
100
            time.sleep(1)
94
            req = urllib2.Request(url)
101
            req = urllib2.Request(url,headers=headers)
95
            response = urllib2.urlopen(req)
102
            response = urllib2.urlopen(req)
96
            json_input = response.read()
103
            json_input = response.read()
97
            vendorInfo = json.loads(json_input)
104
            vendorInfo = json.loads(json_input)
98
            print vendorInfo
105
            print vendorInfo
99
            lowestSp, iterator, ourInventory, lowestSellerInventory,ourSp,ourOfferPrice,lowestSp,lowestOfferPrice   = (0,)*8
106
            lowestSp, iterator, ourInventory, lowestSellerInventory,ourSp,ourOfferPrice,lowestSp,lowestOfferPrice   = (0,)*8