Simple pyamazon example
10 Jun 2003
Someone needed to work out the value of certain books that their company was thinking of selling. Some books had accurate buying price, but those were inflated by the higher dollar exchange rate back then or being impulse buys. So, I wrote this quick python script to use Amazon's "Web Services" get the list price, amazon price, and Amazon Marketplace new and used prices. You'll need Mark Pilgrim's PyAmazon and an Amazon developer key.
#!/usr/bin/env python import sys import time import amazon BOOKS = [ "0-7897-2242-9", "0-13-096288-0", "0-471-35601-8", "1-56592-869-5" ] def main(argv = None): if not argv: argv = sys.argv print ",".join(["ISBN", "List Price", "Amazon Price", "Third Party New Price", "Used Price"]) for book in BOOKS: isbn = book.replace("-", "") bag = amazon.searchByASIN(isbn)[0] lp = getattr(bag, "ListPrice", "") ap = getattr(bag, "OurPrice", "") tpn = getattr(bag, "ThirdPartyNewPrice", "") used = getattr(bag, "UsedPrice", "") print ",".join([isbn, lp, ap, tpn, used]) time.sleep(5) if __name__ == "__main__": sys.exit(main())