目录
频道首页
微信视频号下载器 v1.0
收藏
0
kohler 最近修改于 2023-08-19 07:39:48

前言

  • 不得不说,微信视频号的下载真的是一个老大难问题,每隔一段时间,之前的方法总会失效,然后又需要去找新的工具。翻来覆去颠倒几次之后烦的不行,于是想着直接通过抓包的方法来下载微信视频号,只要自己实时更新一下微信的解析规则,那么这种手动抓包下载的方法基本上就永久可用,说干就干,我们马上开始搞起来。

具体操作

下载标清版本

  • 将要下载的视频分享到微信的文件传输助手中,防止下载错了,之后打开这个视频 img
  • 然后打开Http debug进行抓包,找到finder开头的网址,应该是get方法,资源类型为mp4,复制出来这个网址 img
https://finder.video.qq.com/251/20302/stodownload?encfilekey=Cvvj5Ix3eewK0tHtibORqcsqchXNh0Gf3sJcaYqC2rQDtxG4xibUK1iceLfkxcFazFHEwU39NworItlIaibb4CKaA4GFibfcCmeicicX7a9Fw1BZK9kYr1YtcpQIL2iawt1DvmPN&bizid=1023&dotrans=0&hy=SH&idx=1&m=&upid=0&web=1&token=6xykWLEnztKNJfMkDJQkqv7NTNo7B8TYJljUNmdpz0wQiaQhxbdvZXsJiapiapSibPzSajy3BRO9QJhmUicOcMeZcYibsxib6ica0T4pj99Pkic1lGe1ibSdLGMF9XBTXUJ4db4Gkib&extg=10f002e&svrbypass=AAuL%2FQsFAAABAAAAAAAXIkT4jXzES8%2BxLuTeZBAAAADnaHZTnGbFfAj9RgZXfw6VXkxwlWjwX%2BxfEW6SmjDgkchRBCMywhVTMnVoJS5LWXuv&svrnonce=1692329006&fexam=1&X-snsvideoflag=xWT96
  • 之后将这个网址中的20302修改成20304, img 一个样例
https://finder.video.qq.com/251/20304/stodownload?encfilekey=Cvvj5Ix3eewK0tHtibORqcsqchXNh0Gf3sJcaYqC2rQDtxG4xibUK1iceLfkxcFazFHEwU39NworItlIaibb4CKaA4GFibfcCmeicicX7a9Fw1BZK9kYr1YtcpQIL2iawt1DvmPN&bizid=1023&dotrans=0&hy=SH&idx=1&m=&upid=0&web=1&token=6xykWLEnztKNJfMkDJQkqv7NTNo7B8TYJljUNmdpz0wQiaQhxbdvZXsJiapiapSibPzSajy3BRO9QJhmUicOcMeZcYibsxib6ica0T4pj99Pkic1lGe1ibSdLGMF9XBTXUJ4db4Gkib&extg=10f002e&svrbypass=AAuL%2FQsFAAABAAAAAAAXIkT4jXzES8%2BxLuTeZBAAAADnaHZTnGbFfAj9RgZXfw6VXkxwlWjwX%2BxfEW6SmjDgkchRBCMywhVTMnVoJS5LWXuv&svrnonce=1692329006&fexam=1&X-snsvideoflag=xWT96
  • 之后就可以放到IDM中进行下载了 img
  • 如果下载的格式是jpg的,不用管它,直接强制改成mp4的就行了 img img
  • 可以看到这个视频是可以正常查看与播放的 img

下载高清的微信号视频

  • 不过这个视频下载的是标清版的,如果想下载高清版的还需要对链接进行进一步的处理
  • 保留encfilekey以及token部分,其他的参数全部删掉

标清的视频链接

### https://finder.video.qq.com/251/20304/stodownload?encfilekey=Cvvj5Ix3eewK0tHtibORqcsqchXNh0Gf3sJcaYqC2rQDtxG4xibUK1iceLfkxcFazFHEwU39NworItlIaibb4CKaA4GFibfcCmeicicX7a9Fw1BZK9kYr1YtcpQIL2iawt1DvmPN&bizid=1023&dotrans=0&hy=SH&idx=1&m=&upid=0&web=1&token=6xykWLEnztKNJfMkDJQkqv7NTNo7B8TYJljUNmdpz0wQiaQhxbdvZXsJiapiapSibPzSajy3BRO9QJhmUicOcMeZcYibsxib6ica0T4pj99Pkic1lGe1ibSdLGMF9XBTXUJ4db4Gkib&extg=10f002e&svrbypass=AAuL%2FQsFAAABAAAAAAAXIkT4jXzES8%2BxLuTeZBAAAADnaHZTnGbFfAj9RgZXfw6VXkxwlWjwX%2BxfEW6SmjDgkchRBCMywhVTMnVoJS5LWXuv&svrnonce=1692329006&fexam=1&X-snsvideoflag=xWT96

高清的视频链接

### https://finder.video.qq.com/251/20304/stodownload?encfilekey=Cvvj5Ix3eewK0tHtibORqcsqchXNh0Gf3sJcaYqC2rQDtxG4xibUK1iceLfkxcFazFHEwU39NworItlIaibb4CKaA4GFibfcCmeicicX7a9Fw1BZK9kYr1YtcpQIL2iawt1DvmPN&bizid=1023&dotrans=0&hy=SH&idx=1&m=&upid=0&web=1&token=6xykWLEnztKNJfMkDJQkqv7NTNo7B8TYJljUNmdpz0wQiaQhxbdvZXsJiapiapSibPzSajy3BRO9QJhmUicOcMeZcYibsxib6ica0T4pj99Pkic1lGe1ibSdLGMF9XBTXUJ4db4Gkib
  • 可以看到这个视频的尺寸已相较之前大了很多 img

  • 播放起来的清晰度也相较之前清晰了很多

自动化操作

  • 当然了,这个删除参数的操作很繁琐,而且一不小心就容易出错,因此我把它写成一个Python小程序,可以直接下载下来这个地址中的视频

代码

import tkinter as tk
from tkinter import filedialog
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
import tkinter.font as tkfont
from datetime import datetime
import warnings
import requests

warnings.filterwarnings("ignore")

class AutoClosingDialog(tk.Toplevel):
    def __init__(self, parent, text='', title=None, timeout=2000):
        super().__init__(parent)
        if title:
            self.title(title)
        self.timeout = timeout
        tk.Label(self, text=text).pack()
        self.after(self.timeout, self.destroy)

def remove_parameters(url, params_to_keep):
    parsed_url = urlparse(url)
    query_params = parse_qs(parsed_url.query)
    query_params = {param: query_params[param] for param in params_to_keep if param in query_params}
    encoded_query = urlencode(query_params, doseq=True)
    new_url = urlunparse((
        parsed_url.scheme,
        parsed_url.netloc,
        parsed_url.path,
        parsed_url.params,
        encoded_query,
        parsed_url.fragment
    ))
    return new_url

def download_file(url, save_path):
    response = requests.get(url, stream=True, verify=False)
    response.raise_for_status()
    with open(save_path, 'wb') as file:
        for chunk in response.iter_content(chunk_size=8192):
            file.write(chunk)

def process_url(quality):
    url = entry.get().replace('20302', '20304')

    if quality == 'hd':
        # params_to_keep = ['encfilekey', 'token']
        # new_url = remove_parameters(new_url, params_to_keep=params_to_keep)
        video_type = '(高清)'

    else:
        new_url = url
        video_type = '(标清)'

    current_datetime = datetime.now()
    current_date = current_datetime.strftime("%Y.%m.%d")
    current_time = current_datetime.strftime("%H%M%S")
    filename = f'{current_date}-{current_time}-{quality}{video_type}.mp4'
    save_path = save_path_var.get() + '/' + filename
    print(f"下载链接:{new_url}")
    print(f"保存路径:{save_path}")
    try:
        download_file(new_url, save_path)
        AutoClosingDialog(window, text=f"{quality.upper()} 视频已成功下载到:" + save_path, title="成功")
    except Exception as e:
        AutoClosingDialog(window, text=f"下载{quality.upper()}视频时发生错误:" + str(e), title="错误")

def process_normal_url():
    download_button.config(state='disabled')
    download_hd_button.config(state='disabled')
    process_url('normal')
    download_button.config(state='normal')
    download_hd_button.config(state='normal')

def process_hd_url():
    download_button.config(state='disabled')
    download_hd_button.config(state='disabled')
    process_url('hd')
    download_button.config(state='normal')
    download_hd_button.config(state='normal')

window = tk.Tk()
window.title("微信视频号下载工具 v1.0")
window_width = 700
window_height = 300
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
position_top = int(screen_height / 2 - window_height / 2)
position_right = int(screen_width / 2 - window_width / 2)
window.geometry(f'{window_width}x{window_height}+{position_right}+{position_top}')
font_style = tkfont.Font(family="Arial", size=16)

label = tk.Label(window, text="请输入微信视频号链接", font=font_style)
label.pack()
entry = tk.Entry(window, font=font_style, width=50)
entry.pack()

save_path_var = tk.StringVar()
save_path_var.set("E:/Documents/Desktop")

def choose_save_path():
    save_path = filedialog.askdirectory()
    save_path_var.set(save_path)

save_path_button = tk.Button(window, text="选择保存路径", command=choose_save_path, font=font_style)
save_path_button.pack()

save_path_entry = tk.Entry(window, textvariable=save_path_var, font=font_style, width=50)
save_path_entry.pack()

download_button = tk.Button(window, text="下载普通质量", command=process_normal_url, font=font_style)
download_button.pack()

download_hd_button = tk.Button(window, text="下载高清质量", command=process_hd_url, font=font_style)
download_hd_button.pack()

window.mainloop()
  • 操作界面很简单,没有什么需要说明的地方
  • img
  • img

Win11 x64编译了一个开箱即用的exe:https://kohler.lanzouy.com/ilQ9P15rzg4j

内容大纲
批注笔记
微信视频号下载器 v1.0
ArticleBot
z
z
z
z
主页
Git管理
文章
云文档
讨论
AI文档