示例#1
0
    def updatePriceHistories(self):

        for ware in self.wareList:

            # Get URL for price history
            url = ""

            with PriceInfo('0.js') as priceInfo: 
                url = priceInfo.execute(ware.name, ware.url);

            # Get price histories
            path = 'data/{}.js'.format(ware.wid)
            ret = saveHttpData(path, url)

            # Parse
            historyData = parsePriceHistory(path)

            if historyData:
                ware.setHistories(historyData.histories)

            # os.remove(path)

            print ware

            # Sleep for a while
            time.sleep(random.random())
示例#2
0
    def updatePriceHistories(self):
        def execute(executor, title, url):
            value = 'requestPriceInfo("{}", "{}")'.format(title, url)

            return executor.execute(value)

        executor = JsExecutor('js/huihui.js')

        for ware in self.wareList:

            # Get URL for price history
            url = execute(executor, ware.name, ware.baseUrl)

            # Get price histories
            path = 'data/{}.js'.format(ware.wid)

            # Update from servers
            if not self.isLocal:

                cached = os.path.exists(path)
                if not cached:

                    print 'Update {}'.format(ware.wid)
                    ret = saveHttpData(path, url)
                    if ret < 0: continue

            # Parse
            parser = HhHistoryParser()

            if parser.parse(path):
                historyData = parser.getHistoryData()
                if historyData:
                    ware.setHistories(historyData.histories)

            ware.update()

            # os.remove(path)

            # Sleep for a while
            if not self.isLocal and not cached:
                time.sleep(random.random())

        self.wareList.sort()
示例#3
0
    def updatePriceHistories(self):

        def execute(executor, title, url):
            return executor.context.requestPriceInfo(title, url)

        executor = JsExecutor('js/huihui.js')

        for ware in self.wareList:

            # Get URL for price history
            url = execute(executor, ware.name, ware.baseUrl)

            # Get price histories
            path = 'data/{}.js'.format(ware.wid)

            # Update from servers
            if not self.isLocal:

                cached = os.path.exists(path)
                if not cached:

                    print 'Update {}'.format(ware.wid)
                    ret = saveHttpData(path, url)
                    if ret < 0: continue

            # Parse
            parser = HhHistoryParser()

            if parser.parse(path):
                historyData = parser.getHistoryData()
                if historyData:
                    ware.setHistories(historyData.histories)

            ware.update()

            # os.remove(path)

            # Sleep for a while
            if not self.isLocal and not cached:
                time.sleep(random.random())

        self.wareList.sort()
示例#4
0
    def getJdGids(self):

        gids = []
        gid = 26

        path = 'data/%d.json' % gid

        print "Retrieve {} for indexes".format(path)

        if not self.isLocal:
            ret = saveHttpData(path, 'http://coupon.m.jd.com/seckill/seckillList.json?gid=%d' % gid)
            if ret < 0: return gids

        seckillInfo = SeckillInfo(path)

        # Find all matchesItems
        for matchesItem in seckillInfo.matchesList:
            gids += matchesItem.gid,

        return gids
示例#5
0
    def updateJdWareList(self):

        gids = self.getJdGids()

        for gid in gids:
            path = 'data/%d.json' % gid

            if not self.isLocal:

                cached = os.path.exists(path)
                if not cached:

                    print "Retrieve {}".format(path)

                    ret = saveHttpData(
                        path,
                        'http://coupon.m.jd.com/seckill/seckillList.json?gid=%d'
                        % gid)
                    if ret < 0: continue

            seckillInfo = SeckillInfo(path)

            # Find current matchesItem
            for matchesItem in seckillInfo.matchesList:

                if matchesItem.gid == gid:
                    break

            # Set ware items
            for item in seckillInfo.itemList:

                wItem = WareItem()
                wItem.setSeckillItem(item, matchesItem)

                self.wareList.append(wItem)

            # os.remove(path)

            # Sleep for a while
            if not self.isLocal and not cached:
                time.sleep(random.random())
示例#6
0
    def updateJdWareList(self):

        start = 26
        size = 1
        gids = [x for x in range(start, start + size)]

        for gid in gids:
            path = 'data/%d.json' % gid

            ret = saveHttpData(path, 'http://coupon.m.jd.com/seckill/seckillList.json?gid=%d' % gid)

            if ret < 0: continue

            seckillInfo = SeckillInfo(path)

            for item in seckillInfo.itemList:

                wItem = WareItem()
                wItem.setSeckillItem(item)

                self.wareList.append(wItem)
示例#7
0
    def getJdGids(self):

        gids = []
        gid = 26

        path = 'data/%d.json' % gid

        print "Retrieve {} for indexes".format(path)

        if not self.isLocal:
            ret = saveHttpData(
                path,
                'http://coupon.m.jd.com/seckill/seckillList.json?gid=%d' % gid)
            if ret < 0: return gids

        seckillInfo = SeckillInfo(path)

        # Find all matchesItems
        for matchesItem in seckillInfo.matchesList:
            gids += matchesItem.gid,

        return gids
示例#8
0
    def updateJdWareList(self):

        gids = self.getJdGids()

        for gid in gids:
            path = 'data/%d.json' % gid

            if not self.isLocal:

                cached = os.path.exists(path)
                if not cached:

                    print "Retrieve {}".format(path)

                    ret = saveHttpData(path, 'http://coupon.m.jd.com/seckill/seckillList.json?gid=%d' % gid)
                    if ret < 0: continue

            seckillInfo = SeckillInfo(path)

            # Find current matchesItem
            for matchesItem in seckillInfo.matchesList:

                if matchesItem.gid == gid:
                    break;

            # Set ware items
            for item in seckillInfo.itemList:

                wItem = WareItem()
                wItem.setSeckillItem(item, matchesItem)

                self.wareList.append(wItem)

            # os.remove(path)

            # Sleep for a while
            if not self.isLocal and not cached:
                time.sleep(random.random())