Subversion Repositories SmartDukaan

Rev

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

Rev 4198 Rev 4199
Line 64... Line 64...
64
            else:
64
            else:
65
                return pagination_links[-1]('a')[0]['href'].strip()
65
                return pagination_links[-1]('a')[0]['href'].strip()
66
        except KeyError:
66
        except KeyError:
67
            print pagination_links
67
            print pagination_links
68
 
68
 
-
 
69
    def getDataFromProductPage(self, url):
-
 
70
        html = BaseScraper.read(self, url)
-
 
71
        soup = BeautifulSoup(html)
-
 
72
        name = soup.find('h1', {'itemprop': 'name'}).string.strip()
-
 
73
        price = soup.find('span',{'id': 'fk-mprod-our-id'}).contents[2]
-
 
74
        in_stock = soup.find('div', {'id': 'fk-stock-info-id'}).string.strip()
-
 
75
        
-
 
76
        data = {
-
 
77
            "product_url": str(url), 
-
 
78
            "source": "flipkart", 
-
 
79
            "price": price, 
-
 
80
            "in_stock": 1 if in_stock == 'In Stock.' else 0, 
-
 
81
            "name": name
-
 
82
        }
-
 
83
        return data
-
 
84
 
-
 
85
 
69
if __name__ == '__main__':
86
if __name__ == '__main__':
70
    scraper = HS18Scraper()
87
    scraper = HS18Scraper()
71
    scraper.setUrl('http://www.homeshop18.com//ipads-2f-tablets/categoryid:8937/search:*/start:32/')
88
    scraper.setUrl('http://www.homeshop18.com//ipads-2f-tablets/categoryid:8937/search:*/start:32/')
72
    scraper.scrape()
89
    scraper.scrape()
73
    products = scraper.getPhones()
90
    products = scraper.getPhones()