如何解决通过控制台通过jQuery一次下载mp4文件
我正在新窗口中打开HTML页面。这些页面除其他标签外还具有媒体文件".mp4"
。我可以通过以下代码保存页面:
如何仅下载每个打开的HTML页面内部的媒体? 有没有办法找到并保存这些页面加载的任何媒体?
var anchor = document.getElementsByTagName('a');
for (var i=0; i < anchor.length; i++){
fetch(anchor[i].href)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.setAttribute('target','_blank');
a.download = anchor[i].innerText; // the file name
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
});
}
解决方法
试试这个:
var a = document.getElementsByTagName("video");
for(i of a){
console.log(i.src);
fetch(i.src)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const b = document.createElement('a');
b.style.display = 'none';
b.href = url;
b.setAttribute("download",'arquivo.mp4')
b.download = 'arquivo.mp4'; // the file name
document.body.appendChild(b);
b.click();
window.URL.revokeObjectURL(url);
});
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。