Exemple #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)
Exemple #2
0
 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()
Exemple #3
0
def runMainApp():

    global textPath

    conf = {
        '/static': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.dirname(__file__) + "/serve"
        }
    }

    # Create an instance of MainApp and tell Cherrypy to send all requests under / to it. (ie all of them)
    cherrypy.tree.mount(MainApp(), '/', conf)

    # Tell Cherrypy to listen for connections on the configured address and port.
    cherrypy.config.update({
        'server.socket_host': listen_ip,
        'server.socket_port': listen_port,
        'engine.autoreload.on': True,
    })

    # Start the web server
    cherrypy.engine.start()
    global thread
    thread = MyThread()
    thread.daemon = True
    thread.start()
    # And stop doing anything else. Let the web server take over.
    cherrypy.engine.block()
Exemple #4
0
    def on_button_start_click(self):
        self.button_start.setEnabled(False)
        self.active_thread_count = 0
        links = [
            'google.com', 'youtube.com', 'instagram.com', 'twitter.com',
            'netflix.com'
        ]
        self.threads = []
        for link in links:
            self.thread = MyThread(link)
            self.thread.signals.finished.connect(self.on_finish)
            self.threads.append(self.thread)

        for thread in self.threads:
            self.thread_pool.start(thread)
            self.active_thread_count += 1
from utils import create_connection
from thread import MyThread

connection = create_connection()
profiles_collection = connection["profiles"]
script_path = '/var/InstagramBot/bot/get_followers/get_followers.php'
log_path = '/var/log/InstagramBot/get_followers/'

profiles = profiles_collection.find({'verifyData.verify': True, 'config.profile.numberOfDays': {'$gt': 0}},
                                    {'_id': 1, 'instagramData': 1, 'config': 1})

for profile in profiles:
    MyThread(profile, script_path, log_path).start()
Exemple #6
0
from thread import MyThread

# main
if __name__ == '__main__':
    thread1 = MyThread()
    thread2 = MyThread()

    thread1.start()
    thread2.start()