#!/usr/bin/env python __all__ = ['zhihu_download', 'zhihu_download_playlist'] from ..common import * import json def zhihu_download(url, output_dir='.', merge=True, info_only=False, **kwargs): paths = url.split("/") # question or column if len(paths) < 3 and len(paths) < 6: raise TypeError("URL does not conform to specifications, Support column and question only." "Example URL: https://zhuanlan.zhihu.com/p/51669862 or " "https://www.zhihu.com/question/267782048/answer/490720324") if ("question" not in paths or "answer" not in paths) and "zhuanlan.zhihu.com" not in paths: raise TypeError("URL does not conform to specifications, Support column and question only." "Example URL: https://zhuanlan.zhihu.com/p/51669862 or " "https://www.zhihu.com/question/267782048/answer/490720324") html = get_html(url, faker=True) title = match1(html, r'data-react-helmet="true">(.*?)') for index, video_id in enumerate(matchall(html, [r'