Subversion Repositories SmartDukaan

Rev

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

Rev 12363 Rev 12396
Line 46... Line 46...
46
                    tag.replaceWith(s)
46
                    tag.replaceWith(s)
47
            x.close()
47
            x.close()
48
            sellerCount=0
48
            sellerCount=0
49
            info = []
49
            info = []
50
            sellerData = soup.findAll("div" , {"class" : "a-row a-spacing-mini olpOffer"})
50
            sellerData = soup.findAll("div" , {"class" : "a-row a-spacing-mini olpOffer"})
-
 
51
            dataLength = len(sellerData)
51
            for data in sellerData:
52
            for data in sellerData:
52
                tempMap={}
53
                tempMap={}
53
                price = data.find('span', attrs={'class' : re.compile('.*olpOfferPrice*')}).find('span').text
54
                price = data.find('span', attrs={'class' : re.compile('.*olpOfferPrice*')}).find('span').text
54
                unitCost = float(price.replace("Rs.","").replace(",",""))
55
                unitCost = float(price.replace("Rs.","").replace(",",""))
55
                shippingCost = data.find('p', attrs={'class' : re.compile('.*olpShippingInfo*')}).find('span').text
56
                shippingCost = data.find('p', attrs={'class' : re.compile('.*olpShippingInfo*')}).find('span').text
Line 91... Line 92...
91
                    tempMap['sellerPrice'] = unitCost+shippingCost
92
                    tempMap['sellerPrice'] = unitCost+shippingCost
92
                if sellerCount==3:
93
                if sellerCount==3:
93
                    tempMap['sellerName'] = store.strip()
94
                    tempMap['sellerName'] = store.strip()
94
                    tempMap['sellerPrice'] = unitCost+shippingCost
95
                    tempMap['sellerPrice'] = unitCost+shippingCost
95
                info.append(tempMap) 
96
                info.append(tempMap) 
96
                if sellerCount==3:
97
                if sellerCount==3 or sellerCount==dataLength:
97
                    returnMap[asin] = info 
98
                    returnMap[asin] = info 
98
                    break
99
                    break
99
        if findStore:
100
        if findStore:
100
            return self.findStoreFront(returnMap)
101
            return self.findStoreFront(returnMap)
101
        else:
102
        else:
Line 153... Line 154...
153
        #return soup.title.string
154
        #return soup.title.string
154
            
155
            
155
 
156
 
156
if __name__ == '__main__':
157
if __name__ == '__main__':
157
    urls=[]
158
    urls=[]
158
    urls.append("http://amazon.in/gp/offer-listing/B00CE2LQSW/ref=olp_sort_ps")
159
    urls.append("http://amazon.in/gp/offer-listing/B003SNIN9Q/ref=olp_sort_ps")
159
    urls.append("http://amazon.in/gp/offer-listing")
160
    urls.append("http://amazon.in/gp/offer-listing")
160
#    asin = []
161
#    asin = []
161
#    for a in amazonlisted:
162
#    for a in amazonlisted:
162
#        asin.append(a.asin)
163
#        asin.append(a.asin)
163
#        urls.append('http://www.amazon.in/gp/offer-listing/'+str(a.asin)+'/ref=olp_sort_ps')
164
#        urls.append('http://www.amazon.in/gp/offer-listing/'+str(a.asin)+'/ref=olp_sort_ps')
164
#        if len(urls)==50:
165
#        if len(urls)==50:
165
#            break
166
#            break
166
    print urls
167
    print urls
167
    scraper = AmazonAsyncScraper()
168
    scraper = AmazonAsyncScraper()
168
    'http://www.amazon.in/gp/offer-listing/B00CE2LQSW/ref=olp_sort_ps'
169
    'http://www.amazon.in/gp/offer-listing/B003SNIN9Q/ref=olp_sort_ps'
169
    print len(urls)
170
    print len(urls)
170
    x = scraper.read(urls,True)
171
    x = scraper.read(urls,True)
171
    print x
172
    print x
172
    print "##################"
173
    print "##################"
173
#    fetched = x.items()
174
#    fetched = x.items()