1

只需使用 pytube 模块站点中的示例代码。我已经安装了 pytube。我还尝试通过在命令行中进入 python 来运行它。尝试输入时出现相同的错误

yt = YouTube("YouTube/Link")

(代码下方有错误)

from pytube import YouTube
from pprint import pprint

yt = YouTube("http://www.youtube.com/watch?v=Ik-RsDGPI5Y")

pprint(yt.get_videos())

print(yt.filename)

yt.set_filename('Pulp_Fiction.mp4')

print(yt.filter('mp4')[-1])



pprint(yt.filter(resolution='720p'))


video = yt.get('mp4', '720p')

pprint(yt.videos)


video.download('/home/jralph/')

错误....

(venv) MY-MBP:new ME$ python3 yt.py
Traceback (most recent call last):
  File "yt.py", line 4, in <module>
    yt = YouTube("http://www.youtube.com/watch?v=Ik-RsDGPI5Y")
  File "/Users/MY/new/venv/lib/python3.4/site-packages/pytube/api.py", line 66, in __init__
    self.from_url(url)
  File "/Users/MY/new/venv/lib/python3.4/site-packages/pytube/api.py", line 189, in from_url
    signature = self._get_cipher(stream_map["s"][i], js_url)
  File "/Users/MY/new/venv/lib/python3.4/site-packages/pytube/api.py", line 363, in _get_cipher
    response = urlopen(url)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 161, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 462, in open
    req = meth(req)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 1106, in do_request_
    raise URLError('no host given')
urllib.error.URLError: <urlopen error no host given>
(venv) MYs-MBP:new ME$ 
4

0 回答 0