问题描述
我需要能够得到的所有优惠的列表,使用亚马逊的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)卷曲(请确保您设置页眉或亚马逊将误差)两个http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=new和http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=used
3)要处理的网页数提供总数(发现#NEW span.numberreturned)和15鸿沟制定的页数。
4)你需要分析每个网页,网址是像一些:
如第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
希望这是足够的信息,让你开始,对不起,我没有进入到工作剧本我前一段时间写的。
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列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!