通过控制台使用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);
});
};

最新更新