示例#1
0
class GoogleTrend(Myredis, Gtrend, MyKafka):
    def __init__(self):
        self.redis = Myredis()
        self.gtrend = Gtrend()
        self.kafka = MyKafka('NOTHS-trends-topic')

    def start(self):

        while True:
            time.sleep(randint(60, 90))
            print('starting google trend ...')
            category = self.redis.getNextCategory()
            if category:
                print('reporting on :', category)
                gdata = self.gtrend.get_report(category)
                cdata = self.pack_gdata(gdata, category.decode("utf-8"))

                for data in cdata:
                    list_ = ",".join(data)
                    self.kafka.send(list_)
                print('end')
示例#2
0
class GoogleTrend(Myredis, Gtrend, MyKafka):
    def __init__(self):
        self.redis = Myredis()
        self.gtrend = Gtrend()
        self.kafka = MyKafka("NOTHS-trends-topic")

    def start(self):

        while True:
            time.sleep(randint(60, 90))
            print("starting google trend ...")
            category = self.redis.getNextCategory()
            if category:
                print("reporting on :", category)
                gdata = self.gtrend.get_report(category)
                cdata = self.pack_gdata(gdata, category.decode("utf-8"))

                for data in cdata:
                    list_ = ",".join(data)
                    self.kafka.send(list_)
                print("end")
示例#3
0
 def __init__(self):
     self.redis = Myredis()
     self.gtrend = Gtrend()
     self.kafka = MyKafka('NOTHS-trends-topic')
示例#4
0
 def __init__(self):
     self.redis = Myredis()
     self.gtrend = Gtrend()
     self.kafka = MyKafka("NOTHS-trends-topic")