从亚马逊产品广告 API 获取所有优惠的列表 [英] Get list of ALL offers from Amazon Product Advertising API

查看:26
本文介绍了从亚马逊产品广告 API 获取所有优惠的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够使用亚马逊 API 获取产品的所有优惠列表.这是我发送的请求:

I need to be able to get a listing of all offers for a product using the amazon API. This is the request I'm sending:

http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&Operation=ItemLookup&SubscriptionId=&AssociateTag=&Version=2011-08-01&ItemId=B007IJQDQQ&IdType=ASIN&ResponseGroup=Offers&Condition=All&MerchantId=All

这将返回以下优惠:

<Offers>
<TotalOffers>1</TotalOffers>
<TotalOfferPages>1</TotalOfferPages>
<MoreOffersUrl>
http://www.amazon.com/gp/offer-listing/B007IJQDQQ%3FSubscriptionId%3DAKIAJTZ6VROOTPJAPPWQ%26tag%3Damazoautom-20%26linkCode%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB007IJQDQQ
</MoreOffersUrl>
<Offer>
<OfferAttributes>
<Condition>New</Condition>
</OfferAttributes>
<OfferListing>
<OfferListingId>
TR5sygI0VR7cwy3Hg0DBHwgCWFnkqXLyCR70jjMhy1h8gWlEisKYt5cqDbS2Fu1SEqDtfBILdxYDziJdFzfsqMpPJkBqcYV3DFovHx1nXWRy9wHS6CFZXknBvsCo1bxYS%2BsxAeYrZHrS6g6aakEJQA%3D%3D
</OfferListingId>
<Price>
<Amount>375</Amount>
<CurrencyCode>USD</CurrencyCode>
<FormattedPrice>$3.75</FormattedPrice>
</Price>
<AmountSaved>
<PercentageSaved>56</PercentageSaved>
<Availability>Usually ships in 1-2 business days</Availability>
<AvailabilityAttributes>
<IsEligibleForSuperSaverShipping>0</IsEligibleForSuperSaverShipping>
</OfferListing>
</Offer>
</Offers>

如您所见,即使它说有 3 个新优惠,它也只返回 1 个优惠.有谁知道一种获得所有报价而不仅仅是最低报价的方法?Merchant ID='ALL' 不会这样做,其他任何响应组(例如 offerFull、offerSummary 或 offer)也不会这样做.

As you can see it only returns the 1 offer even though it says there are 3 new offers. Does anyone know of a way to get all the offers and not just the lowest one? Merchant ID='ALL' doesn't do it, neither do any of the other response groups like offerFull, offerSummary, or offers.

推荐答案

在做了一些研究后,这在 API 中是不可能的,但是您可以解析标准页面的 HTML 以获取详细信息:

After doing some research this not possible in the API, however you can parse the HTML of the standard page to get the details:

1) 使用 http://simplehtmldom.sourceforge.net/ 解析 HTML(如果您不使用php,你需要找到类似的东西)

1) Use http://simplehtmldom.sourceforge.net/ for parsing HTML (If your not using php, you'll need find something similar)

2) CURL (确保你设置了你的标题,否则亚马逊会出错) http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=newhttp://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=used

2) CURL (make sure you set your header or amazon will error) both http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=new and http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=used

3) 处理页面计数报价总数(找到#new span.numberreturned)并除以 15 以计算出页面数.

3) To handle pages count total number of offers (found #new span.numberreturned) and divide by 15 to work out number of pages.

4) 您需要解析每个页面,URL 会像一些:

4) You'll need to parse each page, URLs would be like some:

例如第 2 页http://www.amazon.com/gp/offer-listing/B005IMB5SG/?condition=used&startIndex=15

例如第 3 页http://www.amazon.com/gp/offer-listing/B005IMB5SG/?condition=used&startIndex=30

希望这些信息足以帮助您入门,抱歉,我无权访问我不久前编写的工作脚本.

Hope this is enough info to get you started, sorry I don't have access to the working script I wrote a while ago.

这篇关于从亚马逊产品广告 API 获取所有优惠的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆