Differences between version 4 and previous revision of AmazonWishListTextBackup.
Other diffs: Previous Major Revision, Previous Author
@@ -1,35 +1,35 @@
-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.
+
+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/python
-
-import urllib2,re
-
-def getAmazonWishlist(aws_access_id,wishlist_id):
-
- url = 'http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=%s&ListId=%s\
-&ListType=WishList&Operation=ListLookup' % (aws_access_id, wishlist_id)
-
- s = urllib2.urlopen(url).read()
-
- pages = re.findall('<TotalPages>(.+?)</TotalPages>',s)[0]
- 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)
+use Net
::Amazon;
+use Net::Amazon::Request::Wishlist;
- s +
= urllib2.urlopen
(url).read()
+my $ua
= Net::Amazon->new
(
+ token => 'your aws key',
+ secret_key => 'your aws secret',
- return re.findall('<ASIN
>(.+?)</ASIN>.+?<Title>(.+?)<',s
)
+my $req = Net::Amazon::Request::Wishlist->new(
+ id => 'your wishlist id'
+);
-list
= getAmazonWishlist
('<your access id>','<your wishlist id>'
)
+# Response is of type Net::Amazon::ASIN::Response
+my $resp
= $ua->request
($req
);
-for item in list:
-
print item
+if($resp->is_success()) {
+
print $resp->as_string, "\n";
+} else {
+ print $resp->message(), "\n";
+}
version 4
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";
}