Пример #1
0
def index():

    # rec = get_list_rand(0, 6, "all")
    # top = get_list_rand(0, 6, "all")
    # food = get_list(0, 5, "food")
    # movie = get_list(0, 5, "movie")
    # yingxiao = get_list(0, 5, "yingxiao")
    # 以下改為多線程去拉
    t1 = MyThread(get_list_rand, (0,6,"all"))
    t2 = MyThread(get_list, (0,6,"all"))
    t3 = MyThread(get_list, (0,5,"food"))
    t4 = MyThread(get_list, (0,5,"movie"))
    t5 = MyThread(get_list, (0,5,"net"))
    t_list = [t1, t2, t3, t4, t5]
    for t in t_list:
        t.start()
        t.join()
    rec = t1.get_result()
    top = t2.get_result()
    food = t3.get_result()
    movie = t4.get_result()
    net = t5.get_result()
    data = {
        'rec': process_data_index(rec),
        'top':  process_data_index(top),
        'food':  process_data_index(food),
        'movie':  process_data_index(movie),
        'net':  process_data_index(net),
    }
    return render_template('index.html', data=data)
Пример #2
0
Файл: main.py Проект: gmhh/weibo
 def get_and_dom(self):
     # print("cron start")
     # follows = self.w.get_user_follows()
     # for follow in follows:
     #    if self.weibo_handle.dom_weibo_follow(follow):
     #        print("已将微博账号的关注信息存入数据库")
     print("getting weibo from follows")
     w = WeiBo(self.username, self.password)
     weibo_handle = WeiboHandle(self.username, self.password)
     uids = weibo_handle.get_followed_from_database()
     q1 = Queue()
     q2 = Queue()
     for uid in uids:
         q1.put(uid)
     while not q1.empty():
         uid = q1.get()
         t = MyThread(func=w.get_user_weibo, args=(uid,))
         t.start()
         t.join()
         for data in t.get_result():
             q2.put(data)
     while not q2.empty():
         weibo = q2.get()
         t = MyThread(func=weibo_handle.dom_weibo, args=(weibo,))
         t.start()
         t.join()