您可以对 进行 monkeypatch youtube_dl.extractor._ALL_CLASSES,因此 youtube_dl 不会知道您指定的任何其他提取器。import youtube_dldef get_list_of_extractors(extractor_modules): extractors = [] for module in extractor_modules: list_of_extractors = [ getattr(module, name) for name in dir(module) if name.endswith('IE') and name != 'GenericIE' and name.find("Base") == -1 ] extractors = extractors + list_of_extractors return extractorslist_of_extractors = get_list_of_extractors([youtube_dl.extractor.youtube, youtube_dl.extractor.tiktok])youtube_dl.extractor._ALL_CLASSES = list_of_extractorsydl = youtube_dl.YoutubeDL({})ydl.extract_info( 'https://www.youtube.com/watch?v=BaW_jenozKc', download=False # We do not need to download)# causes youtube_dl.utils.DownloadError, because instagram extractor is not in the listydl.extract_info( 'https://instagram.com/p/aye83DjauH', download=False # We do not need to download)