Subversion Repositories SmartDukaan

Rev

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

Rev 8168 Rev 9236
Line 89... Line 89...
89
 
89
 
90
def getSaholicEntityId(data):
90
def getSaholicEntityId(data):
91
    br = getBrowserObject()
91
    br = getBrowserObject()
92
    for i in data:
92
    for i in data:
93
        response = br.open("http://www.91mobiles.com/redir.php?origin=detail&mobileid=%s&storename=saholic.com&sf=&storeflag=1&cc="%(i[0]))
93
        response = br.open("http://www.91mobiles.com/redir.php?origin=detail&mobileid=%s&storename=saholic.com&sf=&storeflag=1&cc="%(i[0]))
94
        ungzipResponse(response, br)
-
 
95
        page = response.read()
-
 
96
        page=page.decode("utf-8")
-
 
97
        soup = BeautifulSoup(page,convertEntities=BeautifulSoup.HTML_ENTITIES)
-
 
98
        link = soup.find("body" , {"class" : ""})
-
 
99
        for a in soup.findAll('a', href=True):
-
 
100
            url = str(a['href'])
94
        url = br.geturl()
101
            print url
95
        print url
102
            end = url.rindex("?afid")
96
        end = url.rindex("?afid")
103
            our_url = url[0:end]
97
        our_url = url[0:end]
104
            print our_url
98
        print our_url
105
            length= len(our_url)
99
        length= len(our_url)
106
            ind = our_url.rfind("-")
100
        ind = our_url.rfind("-")
107
            entityId = url[ind+1:length]
101
        entityId = url[ind+1:length]
108
            print "*****************************"
102
        print "*****************************"
109
            print "Trying to fetch entity id...."
103
        print "Trying to fetch entity id...."
110
            print "EntityId :",entityId   
104
        print "EntityId :",entityId   
111
            print "*****************************"
105
        print "*****************************"
112
 
106
 
113
def ungzipResponse(r,b):
107
def ungzipResponse(r,b):
114
    headers = r.info()
108
    headers = r.info()
115
    if headers['Content-Encoding']=='gzip':
109
    if headers['Content-Encoding']=='gzip':
116
        import gzip
110
        import gzip