Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“如何修复”;HTTP错误400:错误请求“;对于python 3中的Amazon api请求?_Python_Python 3.x_Amazon Product Api - Fatal编程技术网

“如何修复”;HTTP错误400:错误请求“;对于python 3中的Amazon api请求?

“如何修复”;HTTP错误400:错误请求“;对于python 3中的Amazon api请求?,python,python-3.x,amazon-product-api,Python,Python 3.x,Amazon Product Api,我是一名Python初学者,尝试使用Python3.x和Anaconda发出AmazonAPI请求,并得到以下响应。我花了很多时间试图解决这个问题,但没有想出解决办法。 强文本 输入: from amazon.api import AmazonAPI AMAZON_ACCESS_KEY = "..." AMAZON_SECRET_KEY = "..." AMAZON_ASSOC_TAG = "..." amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_

我是一名Python初学者,尝试使用Python3.x和Anaconda发出AmazonAPI请求,并得到以下响应。我花了很多时间试图解决这个问题,但没有想出解决办法。 强文本

输入:

from amazon.api import AmazonAPI

AMAZON_ACCESS_KEY = "..."
AMAZON_SECRET_KEY = "..."
AMAZON_ASSOC_TAG = "..."

amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)

products = amazon.search(Keywords="knoblauchpresse", SearchIndex='All')
for i, product in enumerate(products):
    print(product.title, product.list_price, product.asin)
输出:

HTTPError                                 Traceback (most recent call last)
<ipython-input-39-84eb43d7eab0> in <module>
      8 
      9 products = amazon.search(Keywords="knoblauchpresse", SearchIndex='All')
---> 10 for i, product in enumerate(products):
     11     print(product.title, product.list_price, product.asin)

/anaconda3/lib/python3.7/site-packages/amazon/api.py in __iter__(self)
    542             Yields a :class:`~.AmazonProduct` for each result item.
    543         """
--> 544         for page in self.iterate_pages():
    545             for item in getattr(page.Items, 'Item', []):
    546                 yield AmazonProduct(

/anaconda3/lib/python3.7/site-packages/amazon/api.py in iterate_pages(self)
    559             while not self.is_last_page:
    560                 self.current_page += 1
--> 561                 yield self._query(ItemPage=self.current_page, **self.kwargs)
    562         except NoMorePages:
    563             pass

这是亚马逊网页上的官方模块吗?也许亚马逊改变了API中的某些东西,而这个模块却不知道。嗨@furas谢谢你的评论!我想是的。我怎么能检查呢?它看起来像是这个Github的包装器:上一次发布是在一年多以前。可能就像@furas说的,它可能有一些不推荐的东西@MichaelPlatt你现在有更好的包装吗?我在网上找到了这个,看起来很不错。这是亚马逊网页上的官方模块吗?也许亚马逊改变了API中的某些东西,而这个模块却不知道。嗨@furas谢谢你的评论!我想是的。我怎么能检查呢?它看起来像是这个Github的包装器:上一次发布是在一年多以前。可能就像@furas说的,它可能有一些不推荐的东西@MichaelPlatt你现在有更好的包装吗?我在网上找到了这个,看起来很不错。也许对你更有利
/anaconda3/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 400: Bad Request