Created
April 14, 2012 08:39
-
-
Save cloverrose/2382931 to your computer and use it in GitHub Desktop.
example amazon search using bottlenose and ElementTree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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