gpt4 book ai didi

python - 亚马逊产品广告 API(ItemSearch 和 ItemPage)

转载 作者:行者123 更新时间:2023-12-01 06:00:13 25 4
gpt4 key购买 nike

我编写了以下代码:

from hashlib import sha256
from base64 import b64encode
import hmac
import urllib
from time import strftime, gmtime

url = 'http://ecs.amazonaws.com/onca/xml'
AWSAccessKeyId = amazon_settings.amazon_access_key_id
AssociateTag = amazon_settings.amazon_associate_tag
Keywords = urllib.quote_plus('Potter')
Operation = 'ItemSearch'
SearchIndex = 'Books'
Service = 'AWSECommerceService'
Timestamp = urllib.quote_plus(strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()))
Version = '2011-08-01'

sign_to = 'GET\necs.amazonaws.com\n/onca/xml\nAWSAccessKeyId=%s&AssociateTag=%s&Keywords=%s&Operation=%s&SearchIndex=%s&Service=%s&Timestamp=%s&Version=%s' % (AWSAccessKeyId, AssociateTag, Keywords, Operation, SearchIndex, Service, Timestamp, Version)

Signature = urllib.quote_plus(b64encode(hmac.new(str(amazon_settings.amazon_secret_access_key), str(sign_to), sha256).digest()))

request = '%s?AWSAccessKeyId=%s&AssociateTag=%s&Keywords=%s&Operation=%s&SearchIndex=%s&Service=%s&Timestamp=%s&Version=%s&Signature=%s' % (url, AWSAccessKeyId, AssociateTag, Keywords, Operation, SearchIndex, Service, Timestamp, Version, Signature)

print request

当我使用这段代码时一切都很好。但如果我尝试将 ItemPage 参数添加到 sign_to 变量并请求变量,我会收到错误 SignatureDoesNotMatch。

请帮助我。

最佳答案

这实际上并不能回答你的问题,但我建议你看看亚马逊产品广告 API 的优秀 python 包装器 - python-amazon-product-api

关于python - 亚马逊产品广告 API(ItemSearch 和 ItemPage),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10825629/

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