0

我有一个与https://www.pythonanywhere.com/forums/topic/2688/中突出显示的问题类似的问题

唯一的区别是我使用的是flask,而我使用的模块是pytube。我相信您会提供帮助,显示的错误消息是:

Traceback (most recent call last):
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request() 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e) 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb) 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request() 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functionsrule.endpoint 
File "/home/*username*/<project>/app.py", line 49, in upload
    ytube = YouTube(url) 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/pytube/api.py", line 66, in init
    self.from_url(url) 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/pytube/api.py", line 158, in from_url
    video_data = self.get_video_data() 
File "/home/*username*/.virtualenvs/*project*/local/lib/python2.7/site-packages/pytube/api.py", line 254, in get_video_data
    response = urlopen(self.url) 
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout) 
File "/usr/lib/python2.7/urllib2.py", line 404, in open
    response = self._open(req, data) 
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
    '_open', req) 
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args) 
File "/usr/lib/python2.7/urllib2.py", line 1222, in https_open
    return self.do_open(httplib.HTTPSConnection, req) 
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
    raise URLError(err) URLError: <urlopen error Tunnel connection failed: 403 Forbidden>
4

1 回答 1

4

Youtube 不允许通过其 API 下载视频,因此所有下载 youtube 视频的脚本都会抓取 www 网站,我们不允许从免费帐户中抓取。

更多信息在这里:http ://help.pythonanywhere.com/pages/403ForbiddenError

于 2016-03-06T11:38:26.397 回答