Skip to content

Instantly share code, notes, and snippets.

@cloverrose
Created April 14, 2012 08:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloverrose/2382931 to your computer and use it in GitHub Desktop.
Save cloverrose/2382931 to your computer and use it in GitHub Desktop.
example amazon search using bottlenose and ElementTree
#coding: utf-8
access_key_id=''
secret_key=''
associate_tag='-22'
region='JP'
comic=u'ONE PIECE'
xmlns='{http://webservices.amazon.com/AWSECommerceService/2011-08-01}'
node=2278488051#本>漫画・アニメ・BL>コミック
zassi_node=13384021#本>雑誌
import bottlenose
from xml.etree.ElementTree import fromstring
def get():
amazon=bottlenose.Amazon(access_key_id,secret_key,associate_tag,Region=region)
result=amazon.ItemSearch(Keywords=comic
,SearchIndex='Books'
,ItemPage='1'
,ResponseGroup='Small')
root=fromstring(result)
Items=root.find(xmlns+'Items')
for item in Items.findall(xmlns+'Item'):
print '--'
attrs=item.find(xmlns+'ItemAttributes')
if attrs:
print attrs.findtext(xmlns+'Title')
def getNode():
amazon=bottlenose.Amazon(access_key_id,secret_key,associate_tag,Region=region)
result=amazon.ItemSearch(Keywords=comic
,SearchIndex='Books'
,BrowseNode=node
,ItemPage='1'
,ResponseGroup='Small')
root=fromstring(result)
Items=root.find(xmlns+'Items')
for item in Items.findall(xmlns+'Item'):
attrs=item.find(xmlns+'ItemAttributes')
if attrs:
print attrs.findtext(xmlns+'Title')
def getZassiNode():
amazon=bottlenose.Amazon(access_key_id,secret_key,associate_tag,Region=region)
result=amazon.ItemSearch(Keywords=comic
,SearchIndex='Books'
,BrowseNode=zassi_node
,ItemPage='1'
,ResponseGroup='Small')
root=fromstring(result)
Items=root.find(xmlns+'Items')
for item in Items.findall(xmlns+'Item'):
attrs=item.find(xmlns+'ItemAttributes')
if attrs:
print attrs.findtext(xmlns+'Title')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment