예제 #1
0
 def download_video_page_async_single_process(self):
     key = 'new_tudou_video_url'
     pid = os.getpid()
     while connect_with_redis.length_of_set(key) > 0:
         self.download_video_page_async()
         print("platform: %s, action: download video page, pid: %s" %
               (self.platform, pid))
예제 #2
0
 def download_video_page_async_single_process(self):
     pid = os.getpid()
     key = 'iqiyi_video_url'
     while connect_with_redis.length_of_set(key) > 0:
         loop = asyncio.get_event_loop()
         loop.run_until_complete(self.get_video_page(loop))
         print("platform: %s, action: download video page, process_id: %s" %
               (self.platform, pid))
예제 #3
0
def download_video_page(platform):
    crawler_initialization = get_crawler(platform)
    crawler = crawler_initialization()
    if platform == '腾讯视频':
        key = 'v_qq_url_dict'
    else:
        key= "%s_%s" % (platform, data_cate)
    while True:
        if connect_with_redis.length_of_set(key) > 0:
#            pid_num = connect_with_redis.length_of_set(key=key_set)
#            if pid_num < 20:
#                process_num = int(20-pid_num)
            crawler.download_video_page_async_multi_process()
#            else:
#                print("%s processes is working on %s" % (pid_num, platform))
#                time.sleep(20)
        else:
            print("no %s url [dict] in redis" % platform)
            time.sleep(300)