Boto MWS Python响应问题

时间:2015-06-17 11:44:32

标签: python boto amazon-mws

我正在尝试使用Boto来阅读亚马逊MWS响应以获取ID的匹配产品。我的连接工作正常,并且能够获得结果,但在尝试解析结果时遇到问题。看起来Boto内置了结果解析器,例如ResponseResponseFactory。我只是无法弄清楚如何将信息传递给这些方法,所以我可以实现一些预先构建的代码。

此代码:

mws = MWSConnection(accessKeyId,secretKey,Merchant=merchantId)
response = mws.list_matching_products(MarketplaceId=marketplaceId,Query="Beanie Babies")

打印出这个字符串:

ListMatchingProductsResponse{'xmlns': 'http://mws.amazonservices.com/schema/Products/2011-10-01'}(ResponseMetadata: ^ResponseMetadata^{}(RequestId: '76d4b82c-1a03-40f5-965b-0f63e73435b5'), ListMatchingProductsResult: ListMatchingProductsResult{}(Products: ^Products^{'xmlns': 'http://mws.amazonservices.com/schema/Products/2011-10-01', 'xmlns:ns2': 'http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd'}(Product: [Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B002Q4M5PQ', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Ty', ManufacturerMaximumAge: 144.00{'Units': 'months'}, SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/412YMy2HQ0L._SL75_.jpg', Width: 56{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Binding: 'Toy', IsAutographed: 'false', MediaType: [], IsMemorabilia: 'false', Color: 'Grey/Bluw', ManufacturerMinimumAge: 36{'Units': 'months'}, ProductGroup: 'Toy', Title: 'TY Beanie Boos - Slush - Husky', Platform: [], Artist: [], PackageQuantity: '1', ReleaseDate: '2009-11-16', Brand: 'Ty Beanie Boos', ListPrice: USD 9.99, Studio: 'Ty', Model: '36006', Format: [], NumberOfItems: '1', Author: [], Creator: [], MaterialType: ['All New Material'], Feature: ["Official product from Ty's NEW Beanie Boos Collection", "Look for the familiar heart-shaped tag that means you've purchased an authentic Ty product", 'Handmade with the finest quality standards in the industry', 'Requires no additional gift tag; inside allows you to insert "TO" and "FROM" information', 'Collect them all'], Languages: None, ItemPartNumber: '36006', IsAdultProduct: 'false', Label: 'Ty', Size: 'Small', PartNumber: '36006', PackageDimensions: 2.99inchesx6.54inchesx3.54inchesx0.22pounds, ItemDimensions: 0.13pounds, OperatingSystem: [], Actor: [], ProductTypeName: 'TOYS_AND_GAMES', Manufacturer: 'Ty', Department: 'Toys', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '1199'), SalesRank{}(ProductCategoryId: '251943011', Rank: '6'), SalesRank{}(ProductCategoryId: '11350120011', Rank: '8')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00001QEE0', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Binding: 'Toy', MediaType: [], ManufacturerMinimumAge: 36{'Units': 'months'}, ProductGroup: 'Toy', Genre: 'cute pets', MaterialType: [], PackageQuantity: '1', Manufacturer: 'Ty', PackageDimensions: 2.20inchesx5.80inchesx2.70inchesx0.25pounds, ListPrice: USD 9.99, Author: [], Feature: ['Ty beanie baby', 'Whisper the deer', 'Does have the tag', 'brown with white spots', 'Great condition'], Languages: None, Studio: 'Ty', IsAdultProduct: 'false', ItemDimensions: 4.00inchesx10.00inchesx6.00inchesx0.19pounds, OperatingSystem: [], Actor: [], Director: [], GemType: [], SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/7109TVVS4DL._SL75_.gif', Width: 75{'Units': 'pixels'}, Height: 59{'Units': 'pixels'}), Publisher: 'Ty', ProductTypeName: 'TOYS_AND_GAMES', Platform: [], Artist: [], Brand: 'Beanie Babies', Format: [], Creator: [], Label: 'Ty', PartNumber: '4194', Title: 'TY Beanie Baby - WHISPER the Deer')]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '68255')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B000JK67MQ', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Beanie Babies - Teddy Bears', ManufacturerMaximumAge: 36{'Units': 'months'}, SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/4193jH4e35L._SL75_.jpg', Width: 75{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Title: 'Ty Beanie Babies - Princess Bear', Binding: 'Toy', IsAutographed: 'false', MediaType: [], IsMemorabilia: 'false', Color: 'purple', ManufacturerMinimumAge: 36{'Units': 'months'}, ProductGroup: 'Toy', Genre: 'cute pets', Platform: [], Artist: [], PackageQuantity: '1', Brand: 'Beanie Babies', ListPrice: None, Model: '4300', Format: [], Author: [], Creator: [], MaterialType: [], Feature: ['Ty Beanie Baby', 'Princess Bear', 'Purple with purple bow with white flower', 'Does have the tag'], Languages: None, Studio: 'Beanie Babies - Teddy Bears', IsAdultProduct: 'false', Label: 'Beanie Babies - Teddy Bears', PartNumber: '4300', PackageDimensions: 0.90inchesx7.40inchesx4.50inchesx0.40pounds, Edition: '1997', ItemDimensions: 4.00inchesx10.00inchesx6.00inchesx0.31pounds, OperatingSystem: [], Actor: [], ProductTypeName: 'TOYS_AND_GAMES', Manufacturer: 'Beanie Babies - Teddy Bears', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '38666')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00ROSX26K', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Ty', SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/414%2BgrfnUsL._SL75_.jpg', Width: 73{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Binding: 'Toy', MediaType: [], ProductTypeName: 'TOYS_AND_GAMES', Color: 'white/black', ManufacturerMinimumAge: 36{'Units': 'months'}, ProductGroup: 'Toy', Title: 'Ty Beanie Babies 6" Checkers The Bunny', Platform: [], Artist: [], PackageQuantity: '1', Brand: 'TY', ListPrice: None, Model: '41142', Format: [], Author: [], Creator: [], MaterialType: [], Feature: ["Official product from Ty's wildly popular Beanie Babies Collection", 'Handmade with the finest quality standards in the industry', "Look for the familiar heart-shaped tag that means you've purchased an authentic Ty product", 'Collect Them All!!!'], Languages: ^Languages^{}(Language: [^Language^{}(Name: 'dutch', Type: 'Published'), ^Language^{}(Name: 'english', Type: 'Published'), ^Language^{}(Name: 'french', Type: 'Published'), ^Language^{}(Name: 'german', Type: 'Published'), ^Language^{}(Name: 'italian', Type: 'Published'), ^Language^{}(Name: 'german', Type: 'Unknown')]), Studio: 'Ty', Label: 'Ty', PartNumber: 'TY41142', PackageDimensions: 1.90inchesx4.80inchesx2.90inchesx0.17pounds, ItemDimensions: 5.00inchesx3.98inchesx2.60inchesx0.16pounds, OperatingSystem: [], Actor: [], Manufacturer: 'Ty', Department: 'kids', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '11154')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00342O6WE', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Fun Express', SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/51WlYwdFS0L._SL75_.jpg', Width: 75{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Binding: 'Toy', MediaType: [], ProductTypeName: 'TOYS_AND_GAMES', ManufacturerMinimumAge: 60{'Units': 'months'}, ProductGroup: 'Toy', Title: 'Plush Mini Bean Bag Animal Assortment(50 pcs)', Platform: [], Artist: [], PackageQuantity: '1', Brand: 'Cool Fun', ListPrice: None, Model: '5/387', Format: [], Author: [], Creator: [], MaterialType: ['plush'], Feature: ['Includes 50 small assorted animal bean bags', 'Each has a "to/from" tag so it is ready for gift giving', 'Fun stocking stuffer or birthday party favor for kids', 'Bean bags measure approx. 3 1/2"', 'Assorted colors and designs - pattern may repeat'], Languages: None, Studio: 'Fun Express', Label: 'Fun Express', PartNumber: '5/387', PackageDimensions: 6.20inchesx10.70inchesx8.40inchesx2.15pounds, ItemDimensions: None, OperatingSystem: [], Actor: [], Manufacturer: 'Fun Express', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '4506')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00JVKTK4C', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'TY', SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/51KMXo3UL7L._SL75_.jpg', Width: 50{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Title: 'Ty Beanie Baby "Peace"', Binding: 'Toy', MediaType: [], ProductTypeName: 'TOYS_AND_GAMES', Color: 'Multi', Manufacturer: 'TY', ProductGroup: 'Toy', ManufacturerMinimumAge: 60{'Units': 'months'}, Platform: [], Artist: [], PackageQuantity: '1', Brand: 'TY', ListPrice: None, Model: 'Peace Bear', Format: [], Author: [], Creator: [], MaterialType: [], Feature: ['TY Beanie Baby "Peace"', 'Made of PVC Pellets', '1996', 'Errors on swing tag', 'No number in tush tag'], Languages: None, Studio: 'TY', Label: 'TY', PackageDimensions: 0.60inchesx8.00inchesx3.00inchesx0.30pounds, ItemDimensions: None, OperatingSystem: [], Actor: [], HazardousMaterialType: 'Unknown', Department: 'Womens', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '1168851')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B006YTEM5U', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Ty', ManufacturerMaximumAge: 180.0{'Units': 'months'}, SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/41S%2BIQck7sL._SL75_.jpg', Width: 75{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Binding: 'Toy', MediaType: [], ProductTypeName: 'TOYS_AND_GAMES', Color: 'white, brown, black', ManufacturerMinimumAge: 36.0{'Units': 'months'}, ProductGroup: 'Toy', Title: 'Ty Beanie Baby Banjo Plush - Beagle', Platform: [], Artist: [], PackageQuantity: '1', ReleaseDate: '2012-09-20', Brand: 'Ty Beanie Babies', ListPrice: USD 8.99, Studio: 'Ty', Model: '42069', Format: [], Author: [], Creator: [], MaterialType: ['plush'], Feature: ['Collect Them All', "Look for the familiar heart-shaped tag that means you've purchased an authentic Ty product", 'Handmade with the finest quality standards in the industry', 'High quality for a low price', 'Ty from our heart to yours'], Languages: ^Languages^{}(Language: [^Language^{}(Name: 'italian', Type: 'Manual'), ^Language^{}(Name: 'german', Type: 'Manual'), ^Language^{}(Name: 'french', Type: 'Manual'), ^Language^{}(Name: 'english', Type: 'Manual'), ^Language^{}(Name: 'spanish', Type: 'Manual'), ^Language^{}(Name: 'german', Type: 'Unknown')]), ItemPartNumber: 'TY42069', IsAdultProduct: 'false', Label: 'Ty', PartNumber: 'TY42069', PackageDimensions: 2.60inchesx6.20inchesx4.00inchesx0.05pounds, ItemDimensions: 8.00inchesx3.00inchesx4.00inches, Warranty: 'No Warranty', OperatingSystem: [], Actor: [], Manufacturer: 'Ty', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '11712')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00001QED0', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Beanie Babies', SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/71BZJ2S2BPL._SL75_.gif', Width: 60{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Binding: 'Toy', MediaType: [], ProductTypeName: 'TOYS_AND_GAMES', ManufacturerMinimumAge: 3{'Units': 'months'}, ProductGroup: 'Toy', Title: 'Ty Beanie Babies - Seaweed the Otter', Platform: [], Artist: [], PackageQuantity: '1', Brand: 'Beanie Babies', ListPrice: None, Model: 'TY4080', Format: [], Author: [], Creator: [], MaterialType: [], Feature: [], Languages: None, Studio: 'Beanie Babies', Label: 'Beanie Babies', PartNumber: '4080', PackageDimensions: 1.30inchesx8.00inchesx3.50inchesx0.35pounds, ItemDimensions: 0.02pounds, OperatingSystem: [], Actor: [], Manufacturer: 'Beanie Babies', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '20132')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00S4RLOEW', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Ty', SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/41RtN7iuqoL._SL75_.jpg', Width: 75{'Units': 'pixels'}, Height: 69{'Units': 'pixels'}), Binding: 'Toy', MediaType: [], ProductTypeName: 'TOYS_AND_GAMES', Color: 'White', ManufacturerMinimumAge: 36.00{'Units': 'months'}, ProductGroup: 'Toy', Title: 'Ty Beanie Babies Tundra - White Tiger', Platform: [], Artist: [], PackageQuantity: '1', Brand: 'Ty', ListPrice: None, Model: '42106', Format: [], Author: [], Creator: [], MaterialType: [], Feature: ['Birthday: November 29'], Languages: ^Languages^{}(Language: [^Language^{}(Name: 'german', Type: 'Unknown')]), Studio: 'Ty', Label: 'Ty', Size: '6 inch', PartNumber: '42106', PackageDimensions: 2.91inchesx5.98inchesx4.72inchesx0.22pounds, ItemDimensions: 5.91inchesx1.97inchesx1.97inchesx0.21pounds, OperatingSystem: [], Actor: [], Manufacturer: 'Ty', Department: 'toys', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '4159')])), Product{}(Identifiers: ^Identifiers^{}(MarketplaceASIN: ^MarketplaceASIN^{}(ASIN: 'B00CM6Y1Z0', MarketplaceId: 'ATVPDKIKX0DER'), SKUIdentifier: None), LowestOfferListings: None, Relationships: ^Relationships^{}(VariationParent: []), CompetitivePricing: [], AttributeSets: ^AttributeSets^{}(ItemAttributes: [ItemAttributes{'xml:lang': 'en-US'}(Publisher: 'Ty', ManufacturerMaximumAge: 180.0{'Units': 'months'}, SmallImage: Image{}(URL: 'http://ecx.images-amazon.com/images/I/51gdURVCAsL._SL75_.jpg', Width: 64{'Units': 'pixels'}, Height: 75{'Units': 'pixels'}), Binding: 'Toy', IsAutographed: 'false', MediaType: [], IsMemorabilia: 'false', Color: 'Pinky', ManufacturerMinimumAge: 36.0{'Units': 'months'}, ProductGroup: 'Toy', Title: 'Ty Beanie Boos Pinky Pink Barn Owl Plush', Platform: [], Artist: [], PackageQuantity: '1', Brand: 'Ty Beanie Boos', ListPrice: USD 9.99, Studio: 'Ty', Model: '36094', Format: [], Author: [], Creator: [], MaterialType: ['Polyester'], Feature: ["Official product from Ty's wildly popular Beanie Babies Collection", "Look for the familiar heart-shaped tag that means you've purchased an authentic Ty product", 'Handmade with the finest quality standards in the industry', 'Collect Them All !!!'], Languages: ^Languages^{}(Language: [^Language^{}(Name: 'dutch', Type: 'Published'), ^Language^{}(Name: 'english', Type: 'Published'), ^Language^{}(Name: 'french', Type: 'Published'), ^Language^{}(Name: 'german', Type: 'Published'), ^Language^{}(Name: 'italian', Type: 'Published'), ^Language^{}(Name: 'italian', Type: 'Manual'), ^Language^{}(Name: 'german', Type: 'Manual'), ^Language^{}(Name: 'french', Type: 'Manual'), ^Language^{}(Name: 'english', Type: 'Manual'), ^Language^{}(Name: 'spanish', Type: 'Manual')]), ItemPartNumber: '36094', IsAdultProduct: 'false', Label: 'Ty', Size: '6"', PartNumber: '36094', PackageDimensions: 2.83inchesx5.12inchesx3.86inchesx0.22pounds, ItemDimensions: 7.00inchesx5.00inchesx6.50inchesx0.21pounds, Warranty: 'No Warranty', OperatingSystem: [], Actor: [], ProductTypeName: 'TOYS_AND_GAMES', Manufacturer: 'Ty', Director: [], GemType: [])]), Offers: None, SalesRankings: ^SalesRankings^{}(SalesRank: [SalesRank{}(ProductCategoryId: 'toy_display_on_website', Rank: '1536'), SalesRank{}(ProductCategoryId: '166461011', Rank: '38')]))])))

我确信我可以弄清楚如何使用XML解析器解析XML,但似乎ResponseResponseFactory会让我的生活变得更轻松。我找不到任何真实世界的例子来复制和播放,因为我没有编程背景我不能完全理解所有文档。任何帮助将不胜感激。

0 个答案:

没有答案