Subversion Repositories SmartDukaan

Rev

Rev 9236 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9236 Rev 9354
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
        url = br.geturl()
94
        ungzipResponse(response, br)
95
        print url
95
        page = response.read()
96
        end = url.rindex("?afid")
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):
97
        our_url = url[0:end]
100
            url = str(a['href'])
-
 
101
            end = url.rindex("?afid")
98
        print our_url
102
            our_url = url[0:end]
99
        length= len(our_url)
103
            length= len(our_url)
100
        ind = our_url.rfind("-")
104
            ind = our_url.rfind("-")
101
        entityId = url[ind+1:length]
105
            entityId = url[ind+1:length]
102
        print "*****************************"
106
            print "*****************************"
103
        print "Trying to fetch entity id...."
107
            print "Trying to fetch entity id...."
104
        print "EntityId :",entityId   
108
            print "EntityId :",entityId   
105
        print "*****************************"
109
            print "*****************************"
106
 
110
 
107
def ungzipResponse(r,b):
111
def ungzipResponse(r,b):
108
    headers = r.info()
112
    headers = r.info()
109
    if headers['Content-Encoding']=='gzip':
113
    if headers['Content-Encoding']=='gzip':
110
        import gzip
114
        import gzip