获取Amazon Product Advertising API的所有优惠列表

Gre*_*ngs 24 amazon amazon-web-services amazon-product-api

我需要能够使用amazon API获取产品的所有报价列表.这是我发送的请求:

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
Run Code Online (Sandbox Code Playgroud)

这将返回以下优惠:

<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>
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,它只返回1个报价,即使它说有3个新报价.有没有人知道如何获得所有优惠而不仅仅是最低价?商家ID ='ALL'不会执行此操作,也不会执行任何其他响应组,例如offerFull,offerSummary或​​offer.

dci*_*iso 13

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

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

2)CURL(确保你设置标题或亚马逊会错误)http://www.amazon.com/gp/offer-listing/B007IJQDQQ/?condition=newhttp://www.amazon.com/gp /报价上市/ B007IJQDQQ /?条件=使用

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

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

例如,第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

希望这是足够的信息让你开始,抱歉我无法访问我刚才写的工作脚本.

  • 应该添加哪些标题? (2认同)