如何解决瓶颈导致空对象的错误:预期的字符串或类似字节的对象

时间:2019-03-26 15:17:42

标签: python amazon-product-api bottlenose

我正在服务器上运行代码,当我第一次在服务器上启动时,与Amazon的连接工作正常,但是在某些请求后,它始终会失败。如果我重新启动服务器,它将再次开始工作,但是在以前的相同情况下会失败。我尝试从服务器更改IP,以检查我的IP是否被阻止。但是事实并非如此。我从API中没有得到明确的错误,只有一个空对象错误,所以我不知道如何解决该问题。

这是错误:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/amazon/api.py", line 174, in lookup
    response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 274, in __call__
    {'api_url': api_url, 'cache_url': cache_url})
  File "/usr/local/lib/python3.5/dist-packages/bottlenose/api.py", line 235, in _call_api
    return urllib2.urlopen(api_request, timeout=self.Timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1147, in _send_request
    self.putheader(hdr, value)
  File "/usr/lib/python3.5/http/client.py", line 1083, in putheader
    if _is_illegal_header_value(values[i]):
TypeError: expected string or bytes-like object

非常感谢!

0 个答案:

没有答案