linux gaierror-2,名称或服务名未知),当requests.post在python中使用www.example.com时

huwehgph  于 2023-01-25  发布在  Linux
关注(0)|答案(1)|浏览(170)

我试图通过运行在raspberry pi上的linux发送web请求到我的php代码。我正在使用putty访问操作系统。当我运行代码时,我得到gai错误-2。下面是我的代码:

import requests

values = {'"firstname":' "abc ", '"lastname":' "xyz"}
r = requests.post('http://rts.msmq.site/security.php', data=values)

我找不出问题所在。有人能告诉我可能是什么问题吗?我使用的是Linux。
错误信息:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 94, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/api.py", line 49, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 407, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', gaierror(-2, 'Name or service not known'))
0s0u357o

0s0u357o1#

gaireror代表get_address_info_error,这意味着urllib在访问主机名“http://rts.msmq.site/security.php”时遇到问题,请检查您是否可以访问nslookup rts.msmq.sitedig rts.msmq.siteping rts.msmq.site

相关问题