简体   繁体   English

使用mechanize和pythonanywhere获取“错误隧道连接失败:403 Forbidden”

[英]Getting “error Tunnel connection failed: 403 Forbidden” with mechanize and pythonanywhere

I wrote a small webapp using python, mechanize and flask. 我用python,mechanize和flask写了一个小的webapp。 It works perfectly when I run it locally. 当我在本地运行它时,它工作得很好。

When deployed on pythonanywhere.com , I get an "Internal Server Error" with the following stack trace: 当部署在pythonanywhere.com ,我得到一个带有以下堆栈跟踪的“内部服务器错误”:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1687, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1360, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1358, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1344, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/Lanaru/mysite/gpaviewer.py", line 34, in index
    gpa = get_gpa(request.form['username'], request.form['password'])
**** File "/home/Lanaru/mysite/gpaviewer.py", line 11, in get_gpa
    br.open(r'https://websiteomitted.com/')
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 230, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_opener.py", line 193, in open
    response = urlopen(self, req, data)
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 344, in _open
    '_open', req)
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 332, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 1170, in https_open
    return self.do_open(conn_factory, req)
  File "/usr/local/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py", line 1118, in do_open
    raise URLError(err)
URLError: <urlopen error Tunnel connection failed: 403 Forbidden>

Why am I getting this urlopen error and how can I fix it? 为什么我得到这个urlopen错误,我该如何解决?

If you are using a free account at pythonanywhere.com then keep in mind that access to external sites via urllib2 is restricted to a set of white listed hosts . 如果您在pythonanywhere.com上使用免费帐户,请记住,通过urllib2访问外部网站仅限于一组列入白名单的主机 Paid account can access any external sites. 付费帐户可以访问任何外部网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 <urlopen error Tunnel connection failed: 403 Forbidden>在pythonanywhere服务器上使用geopy时出错 - <urlopen error Tunnel connection failed: 403 Forbidden> error in using geopy on pythonanywhere servers Http - 隧道连接失败:403 Forbidden error with Python web scraping - Http - Tunnel connection failed: 403 Forbidden error with Python web scraping urllib2.URLError: <urlopen error Tunnel connection failed: 403 Tunnel or SSL Forbidden> - urllib2.URLError: <urlopen error Tunnel connection failed: 403 Tunnel or SSL Forbidden> pip install selenium-&#39;隧道连接失败:403禁止访问&#39; - pip install selenium - 'Tunnel connection failed: 403 Forbidden' 错误 ERR_TUNNEL_CONNECTION_FAILED Selenium - Error ERR_TUNNEL_CONNECTION_FAILED Selenium 禁止使用Google Analytics(分析)API获取错误403 - Getting Error with Google Analytics API 403 Forbidden 在 VirusTotal API 上出现 403(禁止)错误 - Getting 403 (forbidden) error on VirusTotal API 使用mechanize获取证书验证失败错误 - Getting certificate verify failed error with mechanize 我想在使用 python mechanize 进行身份验证后获取站点的源。 HTTP 错误 403:禁止 - I want to obtain source of a site after authentication with python mechanize. HTTP Error 403: Forbidden 下载 MNIST 数据集时出现“HTTP 错误 403:禁止”错误 - Getting "HTTP Error 403: Forbidden" error when download MNIST dataset
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM