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

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

问题描述

我需要能够得到的所有优惠的列表,使用亚马逊的API的产品。这是我送的要求:

<$p$p><$c$c>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

这是根据报价返回如下:

 &LT;优惠及GT;
&其中; TotalOffers→1&其中; / TotalOffers&GT;
&其中; TotalOfferPages→1&其中; / TotalOfferPages&GT;
&LT; MoreOffersUrl&GT;
http://www.amazon.com/gp/offer-listing/B007IJQDQQ%3FSubscriptionId%3DAKIAJTZ6VROOTPJAPPWQ%26tag%3Damazoautom-20%26link$c$c%3Dxm2%26camp%3D2025%26creative%3D386001%26creativeASIN%3DB007IJQDQQ
&LT; / MoreOffersUrl&GT;
&LT;优惠&GT;
&LT; OfferAttributes&GT;
&lt;条件&GT;全新&lt; /条件&gt;
&LT; / OfferAttributes&GT;
&LT; OfferListing&GT;
&LT; OfferListingId&GT;
TR5sygI0VR7cwy3Hg0DBHwgCWFnkqXLyCR70jjMhy1h8gWlEisKYt5cqDbS2Fu1SEqDtfBILdxYDziJdFzfsqMpPJkBqcYV3DFovHx1nXWRy9wHS6CFZXknBvsCo1bxYS%2BsxAeYrZHrS6g6aakEJQA%3D%3D
&LT; / OfferListingId&GT;
&LT;价格&gt;
&LT;量&GT; 375 LT; /金额与GT;
&LT;货币code取代;美元&LT; /货币code取代;
&LT; FormattedPrice&GT; $ 3.75 LT; / FormattedPrice&GT;
&LT; /价格&gt;
&LT; AmountSaved&GT;
&LT; PercentageSaved&GT; 56&LT; / PercentageSaved&GT;
&LT;可用性和GT;一般1-2个工作日&LT; /可用性和GT;
&LT; AvailabilityAttributes&GT;
&其中; IsEligibleForSuperSaverShipping&GT; 0℃/ IsEligibleForSuperSaverShipping&GT;
&LT; / OfferListing&GT;
&LT; /发售&GT;
&LT; /优惠及GT;
 

正如你所看到的只是返回1报价,即使它说,有3个新的报价。有谁知道的方式来获得所有的优惠,而不仅仅是最低的一个?商家ID =ALL不这样做,既没有做任何其他的响应组像offerFull,offerSummary,或提供的。

解决方案

在做一些研究,这是不可能的API在后,但你可以分析的标准网页的HTML了解详细内容:

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

2)卷曲(请确保您设置页眉或亚马逊将误差)两个<一href="http://rads.stackoverflow.com/amzn/click/B007IJQDQQ">http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=new和<一href="http://rads.stackoverflow.com/amzn/click/B007IJQDQQ">http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=used

3)要处理的网页数提供总数(发现#NEW span.numberreturned)和15鸿沟制定的页数。

4)你需要分析每个网页,网址是像一些:

如第2页 <一href="http://rads.stackoverflow.com/amzn/click/B005IMB5SG">http://www.amazon.com/gp/offer-listing/B005IMB5SG/?condition=used&startIndex=15

例如,第3页 <一href="http://rads.stackoverflow.com/amzn/click/B005IMB5SG">http://www.amazon.com/gp/offer-listing/B005IMB5SG/?condition=used&startIndex=30

希望这是足够的信息,让你开始,对不起,我没有进入到工作剧本我前一段时间写的。

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

This is returning the follow under offers:

<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>

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.

解决方案

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) Use http://simplehtmldom.sourceforge.net/ for parsing HTML (If your not using php, you'll need find something similar)

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) To handle pages count total number of offers (found #new span.numberreturned) and divide by 15 to work out number of pages.

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

eg page 2 http://www.amazon.com/gp/offer-listing/B005IMB5SG/?condition=used&startIndex=15

eg page 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天全站免登陆