you-get 多线程下载网站视频


#!/usr/bin/python3

import threading import time exitFlag = 0 import subprocess class myThread (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name self.counter = threadID self.i= threadID def run(self): print ("开始线程:" + self.name) print_time(self.name, self.counter, 5) url = " https://www.bilibili.com/video/BV1WJ411k7L3?p={}".format(self.i) command = 'you-get -o F:\\Tcai ' + url print(command) subprocess.call(command, shell=True) print ("退出线程:" + self.name) def print_time(threadName, delay, counter): while counter: if exitFlag: threadName.exit() time.sleep(delay) print ("%s: %s" % (threadName, time.ctime(time.time()))) counter -= 1 threads = [] for i in range(1,259): thread = myThread(i, "Thread-{}".format(i)) thread.start() threads.append(thread) for th in threads: th.jion() print ("退出主线程")

 注意:多线程下载 容易被封IP

可以单线程下载。有点慢哦

#!/usr/bin/python3

import  subprocess
for i in range(300,400):
    url = "https://www.bilibili.com/video/BV1Kb411W75N?p={}".format(i)
    command = 'you-get -o G:\\guigu ' + url
    print(command)
    subprocess.call(command, shell=True)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM