最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【未解决】通过Amazon的API查找某个产品的关键字

Crawl_EmulateLogin crifan 4898浏览 0评论

【背景】

需要,在已经得知一个amazon上某个产品的url等信息后,

如何获得该产品的keyword。

据说,是需要通过amazon的api去查找的。

【解决过程】

1.去查关键字,结果找到:

Searching by Keyword

所以,想到,是否出了以keyword查找之外,还有以产品的ID去查找,比如

http://www.amazon.com/Silver-Linings-Playbook/dp/B00CL68QVQ/ref=sr_1_2?s=instant-video&ie=UTF8&qid=1368688342&sr=1-2

对应的产品的id,很明显是B00CL68QVQ

2.另外,得知了对应的服务是叫做AWS(Amazon Web services)的ItemSeach

3.后来好不容易,找到,或许是所要的:

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html

其可以传递ItemId,比如B00008OE6I然后返回对应的信息,可参考:

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodeLookup.html#ResponsetoSampleRequest

但是问题是,返回的信息中,没有产品的keyword。

4.后来在:

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CHAP_response_elements.html

中找到了,响应值中包含keyword的:

Keywords

The (corrected) words used in a search.

Ancestry: Items/CorrectedQuery

但是,还是无法找到如何查找,才能得到此keyword。

5.发现,好像可以通过:

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CHAP_ResponseGroupsList.html

->

ItemIds

->

Keywords

然后可以得到要的keyword。

所以有空可以去试试。

6.期间,先去搞懂一些概念:

【整理】AWS中的ASIN,ItemId,IdType

7.后来,又了解了关于查询产品信息的一些逻辑:

参考:

http://docs.aws.amazon.com/AWSECommerceService/latest/DG/CHAP_ResponseGroupsList.html

了解到,response group有如下分类:

而其中的,常见的是:

  • ItemAttributes

  • ItemIds

    然后再根据

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/RG_ItemIds.html

    Sample REST Use Case

    All locales.

    http://webservices.amazon.com/onca/xml?
    Service=AWSECommerceService&
    AWSAccessKeyId=[AWS Access Key ID]&
    Operation=ItemLookup&
    ItemId=B000A3UB2O&
    ResponseGroup=ItemIds&
    Version=2011-08-01
    &Timestamp=[YYYY-MM-DDThh:mm:ssZ]
    &Signature=[Request Signature]
    Sample Response Snippet

    The following response snippet shows the elements returned by ItemIds.

      <TotalResults>1</TotalResults>
      <TotalPages>1</TotalPages>
      <Item>
        <ASIN>0976925524</ASIN>
      </Item>
    </Items>

    推导出:

    如果是传递参数是

    ResponseGroup=ItemAttributes

    那么就可以返回对应的属性的信息了。

    (至于是否能找到所要的keyword的,只有以后再看了,暂时是没发现)

    比如:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/RG_ItemAttributes.html

    中的:

  • ItemDimensions

  • 其中,要是ItemDimensions为空,那么参考:

    Null ItemDimensions

    去看一看另外的:PackageDimensions

    但是却也没找到PackageDimensions在哪里有说明。

    8.先不去管细节了。

    先去折腾AWS的AWSAccessKeyId:

    【记录】申请AWS的AWSAccessKeyId(AWS Access Key ID)

    9.另外,也知道了一些相关的资料:

    Documentation Archive>Product Advertising API

    Sample Code & Libraries >Product Advertising API

    Amazon Product Advertising API Best Practices

    然后,从:

    http://aws.amazon.com/cn/resources/

    可以找到N多的资料。

    10.然后继续参考资料,去搞懂如何使用AWS的Access Key Id,因为貌似看到,还有个:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html

    &Signature=[Request Signature]

    的。

    先去看:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/WhatisaWebService.html

    搞懂了:

    • Amazon的WebService提供方式,可以有:REST, SOAP, or XML
    • 对应的发送格式,是通过WSDL (Web Service Definition Language)规定的
    • 很明显,返回的内容,是和编程语言无关的

    然后接着基本搞懂了:

    http://webservices.amazon.com/onca/xml?
    Service=AWSECommerceService&
    Operation=ItemSearch&
    AWSAccessKeyId=[Access Key ID]&
    AssociateTag=[ID]&
    SearchIndex=Apparel&
    Keywords=Shirt
    &Timestamp=[YYYY-MM-DDThh:mm:ssZ]
    &Signature=[Request Signature]

    中的:

     

    11.再去参考:

    Sample Code & Libraries

    ->

    SDK for .NET

    ->

    Getting Started

    发现,貌似真是,足够的繁琐。

    所以,暂时放弃。

    12.后来从:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/SummaryofA2SOperations.html

    发现有:

    其中:

    Find Out More About Specific Items

    像是我要找的。

    结果也还是就是这个ItemLookup

    13.这里是:

    https://forums.aws.amazon.com/forum.jspa?forumID=9

    开发者论坛,以后有不懂的,或许可以先去搜搜,比如那个Signature是如何产生的。

    14.这里:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/FindingItems.html

    以及

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/FindingOutMoreAboutanItem.html

    形象的描述了:

    各种parameter,各种response group,各种ItemSearch相关的内容,都是对应着普通访问页面时的哪个部分。

    15.其实,关于产品有多种变体,也是支持的:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/Variations.html

    16.

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/RESTSyntax.html

    介绍了REST的语法。

    以及相关的:

    Separator Characters

    Separator Characters

    The question mark (?) and ampersand (&) separate the terms in a REST request. The first term in the request must always be the endpoint, which, in the preceding example, is,http://webservices.amazon.com/onca/xml. A question mark always follows the endpoint. The question mark tells the Product Advertising API web servers to start parsing the request for parameters.

    Ampersands separate all of the other parameter name-value pairs in the request. The order of the parameter name-value pairs is inconsequential, as long as they all occur after the question mark.

    17.编程的时候,最好再参考:

    Authenticating REST Requests

    去注意一些url encode的事情。

    18.如果以后有需要的话,可以去使用批量获取:

    Batch Requests

    Performing Multiple ItemLookups in One Request

    19.关于url中包含的那些通用参数,这里有详细解释:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/RequiredParameters.html

    和一些常用的参数,比如Version:

    General, Optional Parameters

    20.关于response响应的解释:

    Anatomy of a Response

    21.想要返回分页等效果,可以参考:

    http://docs.aws.amazon.com/AWSECommerceService/latest/DG/PagingThroughResults.html

     

    22.顺带,发现一个amazon的api的python封装接口:

    https://github.com/redtoad/python-amazon-product-api

    有需要的话,可以去试试的。

     

    23.后来找到一个,关于C#版本的ItemLookup的参考代码:

    REST版本的:

    Product Advertising API Signed Requests Sample Code – C# REST/QUERY

    SOAP版本的:

    Product Advertising API Signed Requests Sample Code – C# SOAP

    有需要的话,可以去试试。

    至少希望里面会有关于如何用SHA256计算出所需的Signature的。

     

    【总结】

    截止到现在,已注册了,有access key ID了,还没去折腾如何具体使用,

    但是至少从逻辑上,从AWS提供的接口上来说,还是没有发现,到底是如何:

    在已知一个产品product的基本信息,比如ASIN,如何获得该产品的keyword。

    其中最接近答案的是:

    通过ItemLookup,得到ItemAttributes Response Group,其中最接近的,也只有Label(只有一个),但是也还是无法得到产品的(可能多个的)keyword。

    转载请注明:在路上 » 【未解决】通过Amazon的API查找某个产品的关键字

    发表我的评论
    取消评论

    表情

    Hi,您需要填写昵称和邮箱!

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    网友最新评论 (4)

    1. 我看到有工具可以实现。我非常非常好奇。
      6年前 (2018-03-18)回复
    2. 不知道你现在实现API查找某个产品的关键字没有。。
      7年前 (2017-03-31)回复
      • 我作为一个懂点技术的亚马逊卖家明确告诉你这个无法实现。
        chaoren927年前 (2017-04-24)回复
        • 嗯。不知道 ziniao 他们的工具到底是怎么实现的抓取search terms的
          7年前 (2017-09-23)回复
    89 queries in 0.198 seconds, using 22.27MB memory