2015-09-06 85 views
-1

我是新来的asp.net和亚马逊产品广告API查找工作........我想从API获取产品的价格。他们已经生成了我生成XML的URL,其中包含产品的详细信息。我只想从“金额”节点中获取金额。我尝试了很多天,但无法完成此任务。可以帮助我。谢谢您。从url的xml亚马逊产品获取pertocular数据Api

回答

0

REST方式

从(AmazonProductAdvtApiSampleCSharpQuery \样本\ SRC)下载文件从https://aws.amazon.com/code/Product-Advertising-API/2480和复制SignedRequestHelper.cs

SignedRequestHelper helper = new SignedRequestHelper("XXXXXXXXXX", "XXXXXXXXXXXXXXXXXXX", "webservices.amazon.com"); 

IDictionary < string, string > dictValue = new Dictionary < string, String >(); 
dictValue["Service"] = "AWSECommerceService"; 
dictValue["Version"] = "2011-08-01"; 
dictValue["Operation"] = "ItemLookup"; 
dictValue["ItemId"] = asinCode; 
dictValue["IdType"] = "ASIN"; 
dictValue["AssociateTag"] = "xxxxxxxxx-xx"; 
dictValue["ResponseGroup"] = "ItemAttributes"; 

string url = helper.Sign(dictValue) 
WebRequest request = WebRequest.Create(url); 
string price; 

using(WebResponse response = await request.GetResponseAsync()) { 
    if (response != null) { 

     using(XmlReader reader = XmlReader.Create(response.GetResponseStream())) { 
      // Now parse XML accordingly 

      reader.ReadToFollowing("ListPrice") 
      if (reader.ReadToDescendant("FormattedPrice")) { 
       price = reader.ReadElementContentAsString();