2

我正在使用 requests 发送带有以下代码的 post 请求:

EMAIL=test@test.com
payload  = {'ref':'EdX7CqkmjCETTSA9MOPvvmmhLE0OH9_D-zjde6lAKsOoKD8','EMAIL':EMAIL,'tag': 'F41D3B010005FB43'}
post_response = requests.post(url='http://p5trc.emv2.com/D2TTF8', params=payload)

我收到以下异常:

  File "C:\Program Files\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydevd.py", line 1090, in run
    pydev_imports.execfile(file, globals, locals) #execute the script
  File "C:\Users\USER\workspace\POST_ME\POST_ME.py", line 72, in <module>
    post_response = requests.post(url='http://p5trc.emv2.com/D2TTF8', params=payload)
  File "C:\Users\USER\workspace\POST_ME\requests\api.py", line 98, in post
    return request('post', url, data=data, **kwargs)
  File "C:\Users\USER\workspace\POST_ME\requests\safe_mode.py", line 39, in wrapped
    return function(method, url, **kwargs)
  File "C:\Users\USER\workspace\POST_ME\requests\api.py", line 51, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\USER\workspace\POST_ME\requests\sessions.py", line 268, in request
    r.send(prefetch=prefetch)
  File "C:\Users\USER\workspace\POST_ME\requests\models.py", line 650, in send
    self._build_response(r)
  File "C:\Users\USER\workspace\POST_ME\requests\models.py", line 313, in _build_response
    request.send()
  File "C:\Users\USER\workspace\POST_ME\requests\models.py", line 636, in send
    raise ConnectionError(sockerr)
requests.exceptions.ConnectionError: [Errno 11004] getaddrinfo failed

从字符串中删除减号字符EdX7CqkmjCETTSA9MOPvvmmhLE0OH9_D-zjde6lAKsOoKD8'tag': 'F41D3B010005FB43' 从字典中删除时,我没有得到异常。

任何想法?

4

1 回答 1

0

多次尝试调用后引发异常,调用getaddrinfo用于将主机名 ( p5trc.emv2.com) 转换为网络地址。您一定是遇到了一些网络问题,您的 DNS 服务器暂时无法访问。

当您更改脚本时它随后起作用的事实与该错误无关。您的 DNS 服务器再次变得可访问。

于 2012-12-04T09:03:15.727 回答