在 python 中的 class 方法中打印不起作用
Printing within a class method in python does not work
我正在尝试从 this website 学习如何在 youtube dl 中添加对新网站的支持
我修改了它,因为该网站已过时。以下是我的代码
from .common import InfoExtractor
class VineIE(InfoExtractor):
_VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
print(webpage)
return []
我的目的是调试和打印变量,看看发生了什么。所以我试试运行吧
python -m youtube_dl vine.co/v/b9KOOWX7HUx
但是,我没有在控制台中获取网页变量。我得到的是?
[generic] b9KOOWX7HUx: Requesting header
WARNING: Falling back on generic information extractor.
[generic] b9KOOWX7HUx: Downloading webpage
[generic] b9KOOWX7HUx: Extracting information
ERROR: Unsupported URL: http://www.vine.co/v/b9KOOWX7HUx
为什么打印功能不起作用?
webpage = self._download_webpage(url, video_id)
好像失败了,你能post那个功能吗?
youtube-dl 已有 VineIE
。您应该编辑该提取器而不是编写一个新提取器。
无论如何,您的代码很可能没有被执行。在 extractors.py
中,通过添加像
这样的行来导入它
from vine import VineIE
再次注意,您的实际提取器不能被调用 VineIE
,因为这样的提取器已经存在。
有关如何创建提取器的更多信息,请关注official documentation on how to create a youtube-dl extractor。
我正在尝试从 this website 学习如何在 youtube dl 中添加对新网站的支持 我修改了它,因为该网站已过时。以下是我的代码
from .common import InfoExtractor
class VineIE(InfoExtractor):
_VALID_URL = r'(?:https?://)?(?:www\.)?vine\.co/v/(?P<id>\w+)'
def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
print(webpage)
return []
我的目的是调试和打印变量,看看发生了什么。所以我试试运行吧
python -m youtube_dl vine.co/v/b9KOOWX7HUx
但是,我没有在控制台中获取网页变量。我得到的是?
[generic] b9KOOWX7HUx: Requesting header
WARNING: Falling back on generic information extractor.
[generic] b9KOOWX7HUx: Downloading webpage
[generic] b9KOOWX7HUx: Extracting information
ERROR: Unsupported URL: http://www.vine.co/v/b9KOOWX7HUx
为什么打印功能不起作用?
webpage = self._download_webpage(url, video_id)
好像失败了,你能post那个功能吗?
youtube-dl 已有 VineIE
。您应该编辑该提取器而不是编写一个新提取器。
无论如何,您的代码很可能没有被执行。在 extractors.py
中,通过添加像
from vine import VineIE
再次注意,您的实际提取器不能被调用 VineIE
,因为这样的提取器已经存在。
有关如何创建提取器的更多信息,请关注official documentation on how to create a youtube-dl extractor。