gpt4 book ai didi

python - Pythonanywhere 上的 "[Errno 111] Connection refused"

转载 作者:太空宇宙 更新时间:2023-11-04 03:14:52 25 4
gpt4 key购买 nike

我正在尝试在 pythonanywhere 上部署我的应用程序,但我无法连接到 Twitter。

这是我得到的错误:-

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/btpraasta/btp_raasta/runServer.py", line 178, in remainingRequests
return (str)(getTrend.get_remainingRequests())
File "/home/btpraasta/btp_raasta/python/getTrend.py", line 20, in get_remainingRequests
data = get_json(url)
File "/home/btpraasta/btp_raasta/python/getTrend.py", line 10, in get_json
connection = urllib.urlopen(url, proxies=proxies)
File "/usr/lib/python2.7/urllib.py", line 87, in urlopen
return opener.open(url)
File "/usr/lib/python2.7/urllib.py", line 208, in open
return getattr(self, name)(url)
File "/usr/lib/python2.7/urllib.py", line 437, in open_https
h.endheaders(data)
File "/usr/lib/python2.7/httplib.py", line 975, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 835, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 797, in send
self.connect()
File "/usr/lib/python2.7/httplib.py", line 1178, in connect
self.timeout, self.source_address)
File "/usr/lib/python2.7/socket.py", line 571, in create_connection
raise err
IOError: [Errno socket error] [Errno 111] Connection refused

我尝试运行的代码是这样的:-

proxies = {'http': 'http://proxy.server:3128'}
connection = urllib.urlopen(url, proxies=proxies)
data = connection.read()

我正在尝试访问以下 URL :- ' https://api.twitter.com/1.1/application/rate_limit_status.json '

我在 pythonanywhere 上有一个免费帐户,并验证了 AP​​I 已列入白名单,并且我正在使用他们在此处描述的代理(http://help.pythonanywhere.com/pages/403ForbiddenError)。

最佳答案

将我的评论复制到正确的答案:让代理与 urllib 一起工作可能很棘手。 requests 通常更易于使用,它从环境变量中提取代理设置。绝对推荐!

关于python - Pythonanywhere 上的 "[Errno 111] Connection refused",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36628136/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com