Example #1
0
    def __init__(self):
        self.scraper = ZaraScrape('en')

        '''
        log.info('-- Removing old database --')
        try:
            os.remove(self.SQL_DATABASE_PATH)
        except:
            pass
        '''

        self.db = DBHelper(self.SQL_DATABASE_PATH)
        self.db.open()
        self.db.createDataBaseTablesIfNotExists()
        self.db.close()
Example #2
0
class Main(object):

    SQL_DATABASE_PATH = 'dressyourself.sqlite'

    def __init__(self):
        self.scraper = ZaraScrape('en')

        '''
        log.info('-- Removing old database --')
        try:
            os.remove(self.SQL_DATABASE_PATH)
        except:
            pass
        '''

        self.db = DBHelper(self.SQL_DATABASE_PATH)
        self.db.open()
        self.db.createDataBaseTablesIfNotExists()
        self.db.close()

    '''
    Run scraping and fills the database
    '''
    def run(self):
        self.scraper.setConfig('man', 'jeans', 'Jean', 'Bottom')
        itemList = self.scraper.run();
        self.fillDataBase(itemList)

        self.scraper.setConfig('man', 'sweatshirts', 'Sweat-shirt', 'Top')
        itemList = self.scraper.run();
        self.fillDataBase(itemList)

        self.scraper.setConfig('man', 'knitwear', 'Knitwears', 'Top')
        itemList = self.scraper.run();
        self.fillDataBase(itemList)

        self.scraper.setConfig('man', 'shoes', 'Shoes', 'Shoes')
        itemList = self.scraper.run(usePlainImage = False);
        self.fillDataBase(itemList)

        self.scraper.setConfig('woman', 'jeans', 'Jean', 'Bottom')
        itemList = self.scraper.run();
        self.fillDataBase(itemList)

        self.scraper.setConfig('woman', 'skirts', 'Skirt', 'Bottom')
        itemList = self.scraper.run();
        self.fillDataBase(itemList)

        self.scraper.setConfig('woman', 'knitwear', 'Knitwears', 'Top')
        itemList = self.scraper.run();
        self.fillDataBase(itemList)

        self.scraper.setConfig('woman', 'shoes', 'Shoes', 'Shoes')
        itemList = self.scraper.run(usePlainImage = False);
        self.fillDataBase(itemList)

        log.info('\n-- Scraping DONE ! --')

    '''
    Fills database with products from scraping
    '''
    def fillDataBase(self, productList):
        self.db.open()

        log.info('-- Starting insertions to database --')
        for product in productList:
            self.db.insertProduct(product)

        self.db.close()