【发布时间】:2018-07-16 18:14:18
【问题描述】:
我有这个用于下载 youtube 视频的脚本
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=kAGacI3JwS4')
#yt.title
#yt.thumbnail_url
#yt.streams.all()
stream = yt.streams.first()
#stream
stream.download('C:\\Users\')
但我希望这基于用户提示模式发生。所以它应该要求用户输入 url 然后从那里进一步下载视频,所以我确实喜欢这个
>>> pk=input("Enter the url:")
Enter the url:https://www.youtube.com/watch?v=GhklL_kStto
>>> pk
'https://www.youtube.com/watch?v=GhklL_kStto'
>>> pk.title
<built-in method title of str object at 0x02362770>
>>> pk.stream()
Traceback (most recent call last):
File "<pyshell#44>", line 1, in <module>
>>pk.stream()
AttributeError: 'str' object has no attribute 'stream'
所以这就是错误。有人可以帮我解决这个问题吗?
感谢您的支持!
【问题讨论】:
标签: python-3.x video youtube pytube