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