Subject: | GoogleBooks ISBN Scraper fail test (+solution) |
Date: | Fri, 21 Feb 2014 11:50:20 +0100 |
To: | bug-WWW-Scraper-ISBN-GoogleBooks_Driver [...] rt.cpan.org |
From: | Lyon Lemmens <lyon.lemmens [...] redlemon.nl> |
LS,
I've been playing around with the excellent ISBN scrapers. But I couldn't get the GoogleBooks
one to install as it failed the tests, not capturing the number of pages correctly.
With a bit of digging I found that google books redirected me to the dutch site
google.books.nl. Which your code captured and adapted the language for correctly. But for
some reason it didn't capture the length of the book. Looking at the source of the HTML page,
I could not see directly what was wrong.
However I did notice that there is a flag in the URL that tells you if a redirect has taken place
(redir_esc=y). Setting this flag to 'n' in the first place prevented the redirection completely.
This means that by setting this flag, you would always go to the main site and you wouldn't
need to jump through the language hoops. That would probably simplify the code a bit.
Anyway, for now I made one change to the code:
124c124
< $data->{url} = $code->{'ISBN:'.$isbn}{info_url};
---
Show quoted text
> $data->{url} = $code->{'ISBN:'.$isbn}{info_url} . '&redir_esc=n';
This makes it always use the main site and all tests now run OK.
--
Regards
Lyon Lemmens