之前看到文章:https://www.52pojie.cn/thread-1822802-1-1.html
但是前置步骤未说明,另外我觉得仅仅只是处理链接使用JS会更合适。
下载视频号的步骤,其实就两步:
1.抓包获取视频链接
2.将视频链接替换到20304的图片服务器便可以直接下载。
如果需要下载高清视频则需要删除链接中的多余参数。
抓包工具下载链接: https://pan.baidu.com/s/1tZeH1BqlKAQx1nOh0lpJDw?pwd=x9xk
HTTP Debugger Pro v9.11安装及汉化指南:- 安装HTTP Debugger Pro v9.11.msi,安装完成后断开网络
- 运行HTTP Debugger Pro KeyGen By DSiDERS.exe点击Activate注册激活后,启动网络
- 将HTTPDebuggerUI_zh.exe放入安装目录,以后用它启动HTTP Debugger
可以考虑将HTTPDebuggerUI_zh.exe发送到桌面快捷方式
这样打开HTTP Debugger Pro后,再打开视频号对应的链接,可以可以看到一堆:
右键随便复制一个链接即可。
然后我们使用JS代码去替换链接为可以下载的链接,已经准备好的完整html代码为:
[HTML] 纯文本查看 复制代码 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover"/>
<title>微信视频号视频下载</title>
</head>
<body>
<textarea placeholder="请输入原始视频下载链接"
style="width: 99%;max-width: 860px;min-height: 200px"></textarea>
<p>
<button class="down1">下载普通视频</button>
<button class="down2">下载高清视频</button>
</p>
<p>
<button class="copy1">复制普通链接</button>
<button class="copy2">复制高清链接</button>
</p>
</body>
<script>
function copyToClipboard(text) {
try {
const textarea = document.createElement('textarea');
textarea.setAttribute('readonly', 'readonly');
textarea.value = text;
document.body.appendChild(textarea);
textarea.select();
let flag = document.execCommand('copy');
document.body.removeChild(textarea);
return flag;
} catch (e) {
console.log(e);
return false;
}
}
let url1, url2;
function parseWxVideoUrl(url) {
let [baseUrl, search] = url.split("?", 2);
const urlParams = new URLSearchParams(search);
let encfilekey = urlParams.get("encfilekey");
let token = urlParams.get("token");
url1 = baseUrl.replace("/20302/", "/20304/") + "?" + search;
return url1 + `?encfilekey=${encfilekey}&token=${token}`;
}
function downloadData(url, e) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onload = (e) => {
let link = document.createElement('a');
link.href = URL.createObjectURL(xhr.response);
link.download = "视频号视频.mp4";
link.click();
};
xhr.onprogress = (event) => {
if (event.lengthComputable) {
e.target.textContent = "下载" + (event.loaded * 100 / event.total).toFixed(1) + '%';
}
};
xhr.send();
}
function copyUrl(url, e) {
let tmp = e.target.textContent;
if (copyToClipboard(url))
e.target.textContent = "复制成功";
else
e.target.textContent = "复制失败";
setTimeout(() => {
e.target.textContent = tmp;
}, 2000);
}
document.querySelector("button.down1").addEventListener("click", evt => downloadData(url1, evt));
document.querySelector("button.down2").addEventListener("click", evt => downloadData(url2, evt));
document.querySelector("button.copy1").addEventListener("click", (event) => copyUrl(url1, event));
document.querySelector("button.copy2").addEventListener("click", (event) => copyUrl(url2, event));
const textarea = document.querySelector('textarea');
textarea.addEventListener('input', (event) => {
const modifiedText = event.target.value;
url2 = parseWxVideoUrl(modifiedText);
document.querySelector("button.down1").textContent = "下载普通视频";
document.querySelector("button.down2").textContent = "下载高清视频";
});
</script>
</html>
将以上代码保存到HTML文件并打开,只要把刚才复制出来的链接粘贴到游览器的输入框中:
点击复制高清链接得到:
[Asm] 纯文本查看 复制代码 https://finder.video.qq.com/251/20304/stodownload?encfilekey=6xykWLEnztKcKCJZcV0rWCM8ua7DibZkibPSZaIgeFjxHdXG667ep3WWuicTxoCdZnevLoAMoPJS5xicCBvsMZ4TYxqCA0vybuNAz4RwPxu67GTtsLib2XImN1CrpAv3FAuB0czTp58wZwOPcSuZjgT57lO1lmruPIC1551fMeBs9I48&token=cztXnd9GyrFgWibaZnNzz3ALIdicHeF3jahXZf267DGXLT6NtRT2h8VY6NHiaZiaXeEMIhdy9ceeJRg53MCRaPkWlXImnibfYjGGWytqIqd1PHm8bS3weLFGKIiaXJoCpdHv5Q
可以看到链接已经处理完毕,点击下载高清视频会在前端后台下载完毕后弹出下载框。
如果你不想自己创建html,可以直接访问 https://ai.shanxl.com/downWxVideo.html
|