Subversion Repositories SmartDukaan

Rev

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

Rev 4199 Rev 4203
Line 67... Line 67...
67
            print pagination_links
67
            print pagination_links
68
 
68
 
69
    def getDataFromProductPage(self, url):
69
    def getDataFromProductPage(self, url):
70
        html = BaseScraper.read(self, url)
70
        html = BaseScraper.read(self, url)
71
        soup = BeautifulSoup(html)
71
        soup = BeautifulSoup(html)
72
        name = soup.find('h1', {'itemprop': 'name'}).string.strip()
72
        name = soup.find('h1', {'id': 'productLayoutForm:pbiName'}).string.replace('Mobile Phone', '').strip()
73
        price = soup.find('span',{'id': 'fk-mprod-our-id'}).contents[2]
73
        price = removePriceFormatting(soup.find('span',{'id': 'productLayoutForm:OurPrice'}).string)
74
        in_stock = soup.find('div', {'id': 'fk-stock-info-id'}).string.strip()
-
 
75
        
74
        
76
        data = {
75
        data = {
77
            "product_url": str(url), 
76
            "product_url": str(url), 
78
            "source": "flipkart", 
77
            "source": "homeshop18", 
79
            "price": price, 
78
            "price": price, 
80
            "in_stock": 1 if in_stock == 'In Stock.' else 0, 
79
            "in_stock": 1,
81
            "name": name
80
            "name": name
82
        }
81
        }
83
        return data
82
        return data
84
 
83
 
85
 
84
 
86
if __name__ == '__main__':
85
if __name__ == '__main__':
87
    scraper = HS18Scraper()
86
    scraper = HS18Scraper()
88
    scraper.setUrl('http://www.homeshop18.com//ipads-2f-tablets/categoryid:8937/search:*/start:32/')
-
 
89
    scraper.scrape()
-
 
90
    products = scraper.getPhones()
-
 
91
    print scraper.getNextUrl()
-
 
92
    print products
-
 
93
87
    print scraper.getDataFromProductPage('http://www.homeshop18.com/samsung-galaxy-note-n7000-mobile-phone/mobiles-accessories/gsm-handsets/product:16601211/cid:3027/')
-
 
88
#    scraper.setUrl('http://www.homeshop18.com//ipads-2f-tablets/categoryid:8937/search:*/start:32/')
-
 
89
#    scraper.scrape()
-
 
90
#    products = scraper.getPhones()
-
 
91
#    print scraper.getNextUrl()
-
 
92
#    print products
-
 
93
94
94