Subversion Repositories SmartDukaan

Rev

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

Rev 12349 Rev 12517
Line 25... Line 25...
25
import email
25
import email
26
from email.mime.multipart import MIMEMultipart
26
from email.mime.multipart import MIMEMultipart
27
import email.encoders
27
import email.encoders
28
import mechanize
28
import mechanize
29
import cookielib
29
import cookielib
-
 
30
from urllib2 import Request
30
 
31
 
31
 
32
 
32
config_client = ConfigClient()
33
config_client = ConfigClient()
33
host = config_client.get_property('staging_hostname')
34
host = config_client.get_property('staging_hostname')
34
syncPrice=config_client.get_property('sync_price_on_marketplace')
35
syncPrice=config_client.get_property('sync_price_on_marketplace')
Line 45... Line 46...
45
lgr.addHandler(fh)
46
lgr.addHandler(fh)
46
 
47
 
47
inventoryMap = {}
48
inventoryMap = {}
48
itemSaleMap = {}
49
itemSaleMap = {}
49
 
50
 
-
 
51
headers = { 
-
 
52
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
-
 
53
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
-
 
54
            'Accept-Language' : 'en-US,en;q=0.8',                     
-
 
55
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
-
 
56
        }
-
 
57
 
-
 
58
 
50
class __Exception:
59
class __Exception:
51
    SERVER_SIDE=1
60
    SERVER_SIDE=1
52
    
61
    
53
 
62
 
54
class __SnapdealDetails:
63
class __SnapdealDetails:
Line 362... Line 371...
362
        
371
        
363
def fetchDetails(supc_code):
372
def fetchDetails(supc_code):
364
    url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=91&sort=sellingPrice"%(supc_code)
373
    url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=91&sort=sellingPrice"%(supc_code)
365
    print url
374
    print url
366
    time.sleep(1)
375
    time.sleep(1)
367
    req = urllib2.Request(url)
376
    req = urllib2.Request(url,headers=headers)
368
    response = urllib2.urlopen(req)
377
    response = urllib2.urlopen(req)
369
    json_input = response.read()
378
    json_input = response.read()
370
    vendorInfo = json.loads(json_input)
379
    vendorInfo = json.loads(json_input)
371
    rank ,otherInventory ,ourInventory, ourOfferPrice, ourSp, iterator, secondLowestSellerSp, secondLowestSellerInventory, \
380
    rank ,otherInventory ,ourInventory, ourOfferPrice, ourSp, iterator, secondLowestSellerSp, secondLowestSellerInventory, \
372
    lowestOfferPrice,  secondLowestSellerOfferPrice = (0,)*10
381
    lowestOfferPrice,  secondLowestSellerOfferPrice = (0,)*10