|
From: Christopher B. <bou...@gm...> - 2010-01-02 16:50:36
|
Amazon differentiates between total review pages, and total pages returned,
but Net::Amazon only uses total pages when determining if it should fetch
more pages or not. I attempted a quick fix, but it has holes. You can use
this as a starting point to get the rest of the reviews, but you will need
to do additional post processing.
If you would like to submit back a patch with the complete fix, I would
gladly incorporate it into Net::Amazon.
Regards,
Christopher
diff --git a/lib/Net/Amazon.pm b/lib/Net/Amazon.pm
index f2f775c..0ff5d1f 100644
--- a/lib/Net/Amazon.pm
+++ b/lib/Net/Amazon.pm
@@ -495,15 +495,41 @@ sub is_page_error {
sub is_page_available {
##################################################
my($self, $ref, $new_items, $page) = @_;
+
+ return $self->is_item_page_available($ref, $page) ||
+ $self->is_review_page_available($ref, $page);
+}
+
+##################################################
+sub is_item_page_available {
+##################################################
+ my($self, $ref, $page) = @_;
+
if(exists $ref->{Items}->{TotalPages} and
$ref->{Items}->{TotalPages} > $page and
$IS_CANNED ne 1) {
- DEBUG("Page $page of $ref->{Items}->{TotalPages} fetched -
continuing");
+ DEBUG("Item Page $page of $ref->{Items}->{TotalPages} fetched -
continuing");
+ return 1;
+ }
+ return 0;
+}
+
+##################################################
+sub is_review_page_available {
+##################################################
+ my($self, $ref, $page) = @_;
+
+ if(exists $ref->{Items}->{Item}->{CustomerReviews} and
+ exists $ref->{Items}->{Item}->{CustomerReviews}->{TotalReviewPages}
and
+ $ref->{Items}->{Item}->{CustomerReviews}->{TotalReviewPages}
> $page and
+ $IS_CANNED ne 1) {
+ DEBUG("Review Page $page of
$ref->{Items}->{Item}->{CustomerReviews}->{TotalReviewPages} fetched -
continuing");
return 1;
}
return 0;
}
+
##################################################
sub xmlref_add {
##################################################
On Fri, Jan 1, 2010 at 11:46 AM, zhang kunpeng <kpz...@gm...> wrote:
> Hello,
>
> I am a graduate student at Northwestern University. I am using Net::Amazon
> package to do my project. I have a question: for each review_set object, I
> could get only 5 reviews for each product which definitely has more than 5
> customer reviews. I know 5 reviews is the 1 page request. How can I make
> more requests and get all reviews for each product? Looking forward to
> hearing from you. Thanks so much. The perl coding is listed as follows.
>
> my $ua = Net::Amazon->new(
> token => 'AKIAJZ7VA53FNCB3DUTA',
> secret_key => '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',
> max_pages => $page);
>
> my $response = $ua->search(browsenode=>"$browsenode",
> mode=>"$searchindex");
>
> if($response->is_success()) {
> foreach my $obj ($response->properties){
> my $rset = $obj->review_set();
> foreach my $rev ($rset->reviews()){
> print $rev->content();
> }
> }
> }
>
>
> --
> KZ
> Phd student
> EECS@Northwestern University
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and
> easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> Net-amazon-devel mailing list
> Net...@li...
> https://lists.sourceforge.net/lists/listinfo/net-amazon-devel
>
>
|