Exemplo n.º 1
0
 def __init__(self, workqueue):
     threading.Thread.__init__(self)
     self.workQueue = workqueue
     self.setDaemon(True)
     self.start()
     self.mongodb = MongoDB()
     self.checkMongoDB = TempMongoDB()
Exemplo n.º 2
0
 def __init__(self, workQueue, saveQueue, timeout=30):
     threading.Thread.__init__(self)
     self.timeout = timeout
     self.setDaemon(True)
     self.workQueue = workQueue
     self.saveQueue = saveQueue
     self.mongodb = MongoDB()
     self.start()
Exemplo n.º 3
0
 def __init__(self):
     self.comment = NewsComment()
     self.mongo = MongoDB()
     self.conn = MySQLdb.connect('localhost',
                                 'root',
                                 '1995',
                                 'newsurl',
                                 charset='utf8',
                                 use_unicode=True)
     self.cursor = self.conn.cursor()
     self.message = NewsMessage()
Exemplo n.º 4
0
 def __init__(self):
     self.mongo = MongoDB()
Exemplo n.º 5
0
 def __init__(self):
     self.comment = NewsComment()
     self.mongo = MongoDB()
     self.huan = huanCun()
Exemplo n.º 6
0
 def __init__(self):
     self.comment = NewsComment()
     self.mongo = MongoDB()
     self.huan = huanCun()
     '''self.genzong = genZong()'''
Exemplo n.º 7
0
 def __init__(self, savequeue):
     self.saveQueue = savequeue
     self.check_mongodb = TempMongoDB()
     self.update_mongodb = MongoDB()
Exemplo n.º 8
0
        updateUrl_Queue = Queue.Queue()
        # First: check old news' url for update
        Updater = CheckUpdate(savequeue=updateUrl_Queue)
        Updater.run()
        CommentPool = ThreadPoolOfCommentThread(num_of_threads=10, workqueue=updateUrl_Queue)
        CommentPool.wait_for_complete()
        print "UPDATE: Complete checking for the old news!"
        # Second: Get all news' url for json
        for url in Urls:
            StartUrlQueue.put(url)
        fetch_1 = MyFetchThreadFirst(workQueue=StartUrlQueue, saveQueue=Json_Url_Queue)
        fetch_1.join()
        # Third: Parse json data and get news' html and parse to generate the message_dict then save it
        print "FETCH: There are %d newest news has been fetched today" % Json_Url_Queue.qsize()
        FetchSecondPool = ThreadPoolOfFetchSecond(num_of_threads=6, workqueue=Json_Url_Queue, savequeue=urlInfo_Queue)
        FetchSecondPool.wait_for_complete()
        # Forth: Request the comment_url and save comment's message_dict
        CommentPool = ThreadPoolOfCommentThread(num_of_threads=10, workqueue=urlInfo_Queue)
        CommentPool.wait_for_complete()
        start_uptime, end_uptime = getCondition()
        time_condition = {"do_time": {"$gte": start_uptime, "$lt": end_uptime},
                          "zhan_dian": "网易新闻"}
        temp_mongo = MongoDB()
        num_of_comments = temp_mongo.get_comment_data(time_condition)
        print "FETCH: There are %d comments has been fetched today" % num_of_comments
        print "TIME: Total spent %d seconds" % (time.time() - start_moment)
        print "SLEEP: Mission complete, start to sleeping.... "
        sleep_seconds = DeltaSeconds()
        time.sleep(sleep_seconds)

Exemplo n.º 9
0
 def __init__(self):
     self.comment = NewsComment()
     self.mongo = MongoDB()
     self.f = open('test.txt', "r+")
     self.i = 0
     self.url_list =[]