Diff: AmazonWishListTextBackup

Differences between current version and predecessor to the previous major change of AmazonWishListTextBackup.

Other diffs: Previous Revision, Previous Author

Newer page: version 6 Last edited on February 29, 2012 11:12 pm by PhilHollenback
Older page: version 3 Last edited on January 28, 2009 1:47 pm by PhilHollenback Revert
@@ -1,61 +1,32 @@
-Here's a python script ( based almost entirely on something [written by Jon Udell|http://blog.jonudell.net/2008/10/25/pyaws-fermats-last-theorem-and-search-diversity/]) that queries Amazon's REST interface and generates a text version of your wishlist . The output is all your wishlist items, one per line in the format <code>ISBN Title</code>. Note you need to supply your wishlist ID, which you can find by examining the your wishlist URL on the Amazon website. You also need an Amazon Web Service access key, which you can obtain at the [AWS website|http://aws.amazon.com/] (it's free)
+*Update:* this page previously contained a python script based almost entirely on something [written by Jon Udell|http://blog.jonudell.net/2008/10/25/pyaws-fermats-last-theorem-and-search-diversity/]. However as of October 2009 Amazon requires you to use your secret key for REST queries so that code no longer works
  
-Obviously this script could be improved tremendously
+Luckily, the perl [Net::Amazon|http://search.cpan.org/~boumenot/Net-Amazon-0.59/lib/Net/Amazon.pm] module has just been updated to work with the new Amazon requirements. With a very small amount of tweaking of an example form that module I was able to once again create a script which dumps my wishlist as a text file. You still need to supply your wishlist ID from your wishlist URL on the Amazon website. You also need to provide both your AWS access key and your secret key, both of which are available for free at the [AWS website|http://aws.amazon.com/]. You will also need to install the ~Net::~Amazon module from CPAN
  
-<verbatim>  
-#!/usr/bin/python  
+Once again this is a terrible, terrible script. Note that Amazon returns results in fixed 'pages' of 10, so you have to supply a number of total pages ahead of time. ~Net::~Amazon does one query per second to comply with Amazon rules so this can take a while. I have about 650 wishlist items so I just set the number or pages to 100 for a maximum of 1000 results (and a fixed script runtime of 100 seconds).  
  
-import urllib2,re  
+{{{  
+#!/usr/bin/perl -w  
  
-def getAmazonWishlist(aws_access_id,wishlist_id)
+use Net ::Amazon;  
+use Net::Amazon::Request::Wishlist;  
  
- url = 'http ://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=%s&ListId=%s\  
-&ListType =WishList&Operation=ListLookup ' % ( aws_access_id , wishlist _id)  
+my $ua = Net ::Amazon->new(  
+ token => 'your aws key' ,  
+ secret _key => 'your aws secret',  
  
- s = urllib2.urlopen(url).read(
+ max_pages => 100  
+ );  
  
- pages = re.findall('<TotalPages >(.+?)</TotalPages >',s )[0]  
+my $req = Net::Amazon::Request::Wishlist- >new (  
+ id = > 'your wishlist id'  
+ );  
  
- for page in range(int(pages)) :  
- url = 'http ://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=%s&ListId=%s\  
-&ProductPage=%s&ListType=WishList&Operation=ListLookup&ResponseGroup =ListFull' % (aws_access_id, wishlist_id, page+1
+# Response is of type Net ::Amazon::ASIN::Response  
+my $resp = $ua->request ($req );  
  
- s += urllib2.urlopen (url).read()  
-  
- return re.findall('<ASIN >(.+? )</ASIN>.+?<Title>(.+? )<',s)  
-  
-  
-list = getAmazonWishlist('<your access id>','<your wishlist id>')  
-  
-for item in list:  
- print item  
-</verbatim>  
-  
- -----  
-  
-<?plugin RawHtml  
-<script >  
-var idcomments _acct = '011e5665a1128cdbe79c8077f0f04353';  
-var idcomments_post_id;  
-var idcomments_post_url;  
-</script>  
-<span id= "IDCommentsPostTitle " style="display:none"></span>  
-<script type='text/javascript' src='http://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>  
-?>  
-  
------  
-  
-<?plugin RawHtml  
-<center >  
-<script type= "text/javascript"><!--  
-google_ad_client = "pub-5011581245921339 ";  
-google_ad_width = 728;  
-google_ad_height = 90;  
-google_ad_format = "728x90_as";  
-google_ad_channel ="";  
-//--></script>  
-<script type="text/javascript"  
- src="http://pagead2.googlesyndication.com/pagead/show_ads.js">  
-</script>  
-</center>  
-?>  
+if ($resp- >is_success ()) {  
+ print $resp ->as _string, "\n ";  
+} else {  
+ print $resp ->message(), "\n ";  
+}  
+}}}  

current version

Update: this page previously contained a python script based almost entirely on something written by Jon Udell. However as of October 2009 Amazon requires you to use your secret key for REST queries so that code no longer works.

Luckily, the perl Net::Amazon module has just been updated to work with the new Amazon requirements. With a very small amount of tweaking of an example form that module I was able to once again create a script which dumps my wishlist as a text file. You still need to supply your wishlist ID from your wishlist URL on the Amazon website. You also need to provide both your AWS access key and your secret key, both of which are available for free at the AWS website. You will also need to install the Net::Amazon module from CPAN.

Once again this is a terrible, terrible script. Note that Amazon returns results in fixed 'pages' of 10, so you have to supply a number of total pages ahead of time. Net::Amazon does one query per second to comply with Amazon rules so this can take a while. I have about 650 wishlist items so I just set the number or pages to 100 for a maximum of 1000 results (and a fixed script runtime of 100 seconds).

#!/usr/bin/perl -w

use Net::Amazon;
use Net::Amazon::Request::Wishlist;

my $ua = Net::Amazon->new(
    token      => 'your aws key',
    secret_key => 'your aws secret',

    max_pages => 100
);

my $req = Net::Amazon::Request::Wishlist->new(
    id  => 'your wishlist id'
);

# Response is of type Net::Amazon::ASIN::Response
my $resp = $ua->request($req);

if($resp->is_success()) {
    print $resp->as_string, "\n";
} else {
    print $resp->message(), "\n";
}


Our Founder
ToolboxClick to hide/show