最近从网上扒拉了许多的学习资料,发现一个一个手动重命名下载真的太伤身体了,然后就想想是否可以用python来操作迅雷一键下载我想要的学习资料,网上找了一圈,发现是真的可以下载,真的牛!!!再也不用一个一个点击下载了,真TM太爽了。
from win32com.client import Dispatch
import csv
class Downloader(object):
def __init__(self):
self.thunder_name = "ThunderAgent.Agent64.1"
self.download_path = "D:\迅雷下载"
def read_csv_standard(self, file_path):
data = []
with open(file_path, encoding="utf-8", mode='r') as file:
reader = csv.reader(file)
for row in reader:
data.append(row)
return data
def work(self):
thunder = Dispatch('ThunderAgent.Agent64.1')
rows = self.read_csv_standard("文件.csv")
for index, row in enumerate(rows):
if 4000 < index <= 5000:
print(row[1])
# row[-2] 为文件链接 row[1]为文件名称
thunder.AddTask(row[-2], row[1] + ".m3u8", self.download_path)
thunder.CommitTasks()
if __name__ == '__main__':
downloader = Downloader()
downloader.work()