注意:需要放在web服务器里运行这个html文件,而不是直接双击打开。代码中的视频链接也只是一个示例,需要自己找新链接。
浏览器下载
function handleDownload() {
let link = '视频网络地址'
let fileName = '文件名字.mp4'
let x = new XMLHttpRequest()
x.open('GET', link, true)
x.responseType = 'blob'
x.onload = (e) => {
let url = window.URL.createObjectURL(x.response)
let a = document.createElement('a')
a.href = url
a.download = fileName
a.click()
}
x.send()
}
迅雷下载,参考链接 https://open.thunderurl.com/#/
function handleXunLeiDownload() {
// 创建单个任务
thunderLink.newTask({
tasks: [
{
url: '视频网络地址', // 指定下载地址【必填项】
},
],
})
}