def testTracks(self): cds = ecs.ItemSearch('Gotterdammerung', SearchIndex='Classical', ResponseGroup='Tracks') cd = cds[1].Tracks self.assertEqual(len(cd.Disc), 2) self.assertEqual(cd.Disc[0].Track[5], 'The Rheingold: Journey Down To Nibelheim') self.assertEqual(cd.Disc[1].Track[3], 'Parsifal: Good Friday Music')
def testAccessories(self): # We have to use Palm Tungsten X items = ecs.ItemSearch('Zen', SearchIndex='Electronics', ResponseGroup='Small,Accessories') for i in range(20): try: self.assertAccessories(items[i]) except IndexError: pass
def testLarge(self): items = ecs.ItemSearch('XML Python', SearchIndex='Books', ResponseGroup='Large') self.assertTrue(items) for i in range(20): try: self.assertLarge(items[i]) except IndexError: pass
def testMedium(self): items = ecs.ItemSearch("XML Python", SearchIndex="Books", ResponseGroup='Request,Medium') self.assertTrue(items) for i in range(20): try: self.assertMedium(items[i]) except IndexError: pass
def testSubjects(self): books = ecs.ItemSearch('XML Python', SearchIndex='Books', MerchantId='All', ResponseGroup='Subjects') book = books[0] subs = book.Subjects self.assert_('HTML' in subs) self.assert_('Computers' in subs) self.assert_('Programming Languages - Perl' in subs)
def testReviews(self): books = ecs.ItemSearch('XML Python', SearchIndex='Books', MerchantId='All', ResponseGroup='Reviews') book = books[4] self.assert_(len(book.CustomerReviews) > 10) # arbitary reviewer self.assertEqual(book.CustomerReviews[3].Reviewer.Name, 'M. Bennett') self.assertEqual(book.CustomerReviews[10].Summary, 'Nice followup')
def testOfferFull(self): items = ecs.ItemSearch('XML Python', SearchIndex='Books', MerchantId='All', ResponseGroup='OfferFull') self.assertTrue(items) for i in range(20): try: self.assertOfferFull(items[i]) except IndexError: pass
def testSimilarities(self): books = ecs.ItemSearch('XML Python', SearchIndex='Books', MerchantId='All', ResponseGroup='Similarities') book = books[0] sim = book.SimilarProducts self.assertEqual(len(sim), 5) self.assertEqual( sim[0].Title, 'Professional JavaScript for Web Developers (Wrox Professional Guides)' ) self.assertEqual( sim[1].Title, 'Professional Ajax, 2nd Edition (Programmer to Programmer)') self.assertEqual(sim[3].Title, 'Ajax in Action')
def setUp(self): # prepare the python books to add self.books = ecs.ItemSearch("python", SearchIndex="Books") self.cart = None
def testItemSearch(self): books = ecs.ItemSearch("", Title="Python", SearchIndex="Books") self.assert_( len(books) > 200, "We are expect more than 200 books are returned.") self.assertNotEqual(books[100], None)
if (searchLocale != "us"): searchMode = "Books-" + searchLocale for searchField in fields: if (searchLocale != "" and searchField != ""): collection = doc.createElement("List") collection.setAttribute("name", "Amazon Import") root.appendChild(collection) pythonBooks = None if searchField == "authors": pythonBooks = ecs.ItemSearch('', Author=query, SearchIndex=searchMode) elif searchField == "asin": pythonBooks = ecs.ItemLookup(query) else: pythonBooks = ecs.ItemSearch('', Title=query, SearchIndex=searchMode) for book in pythonBooks: try: bookElement = doc.createElement("Book") # book = ecs.ItemLookup(book.ASIN)[0] bookElement.setAttribute("title", book.Title)
from pprint import pprint import ecs def get_infos(books): book_info = dict() for book in books: book_info[book.ASIN] = dict() for mtd in dir(book): if mtd[0] != '_': book_info[book.ASIN][mtd] = eval('book.%s' % mtd) return book_info if __name__ == "__main__": ecs.setLicenseKey('0J356Z09CN88KB743582') #books = ecs.ItemSearch('python', SearchIndex='Books') books = ecs.ItemSearch( '0465027814', SearchIndex='Books', ResponseGroup= 'TagsSummary,Tags,ItemAttributes,EditorialReview,Images,Similarities,PromotionalTag' ) pprint(get_infos(books))