Skip to content

Instantly share code, notes, and snippets.

@yutakashino
Created February 19, 2012 15:33
Show Gist options
  • Save yutakashino/1864337 to your computer and use it in GitHub Desktop.
Save yutakashino/1864337 to your computer and use it in GitHub Desktop.
a usage of bottlenose
#!/usr/bin/python
#coding:utf-8
import bottlenose
AMAZON_ACCESS_KEY_ID = "AKIA..............."
AMAZON_SECRET_KEY = "NC.............................."
AMAZON_ASSOC_TAG = "yutakashino-22"
amazon = bottlenose.Amazon(AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG, Region='JP')
res = amazon.ItemLookup(ItemId="4588120824", ResponseGroup="Images",SearchIndex="Books", IdType="ISBN",Style="http://xml2json-xslt.googlecode.com/svn/trunk/xml2json.xslt")
print res
#from xml.etree.ElementTree import *
#res = amazon.ItemSearch(Keywords="ヒューム".decode(), SearchIndex='Books', ItemPage='1', ResponseGroup='Small')
#elem = fromstring(res)
#for e in elem.getiterator():
# print e.tag
from BeautifulSoup import BeautifulStoneSoup
res = amazon.ItemSearch(Keywords="ヒューム".decode(), SearchIndex='Books', ItemPage='1', ResponseGroup='Small')
soup = BeautifulStoneSoup(res)
print "total = %s" % soup.find("totalresults").contents[0]
for i in soup.findAll("item"):
print i.author.contents[0], i.title.contents[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment