| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::Scraper::ISBN::AmazonFR_Driver; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
266289
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
116
|
|
|
4
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
100
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
17
|
use vars qw($VERSION); |
|
|
3
|
|
|
|
|
16
|
|
|
|
3
|
|
|
|
|
199
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.02'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
WWW::Scraper::ISBN::AmazonFR_Driver - Search driver for the (FR) Amazon online |
|
14
|
|
|
|
|
|
|
catalog. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
See parent class documentation (L) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Searches for book information from the (FR) Amazon online catalog. |
|
23
|
|
|
|
|
|
|
This module is a mere paste and translation of |
|
24
|
|
|
|
|
|
|
L. The main (only?) difference is |
|
25
|
|
|
|
|
|
|
in the parsing of the result. Here it is done with simple regexp, whereas in |
|
26
|
|
|
|
|
|
|
L it was done using |
|
27
|
|
|
|
|
|
|
L. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
########################################################################### |
|
34
|
|
|
|
|
|
|
#Inheritence # |
|
35
|
|
|
|
|
|
|
########################################################################### |
|
36
|
|
|
|
|
|
|
|
|
37
|
3
|
|
|
3
|
|
15
|
use base qw(WWW::Scraper::ISBN::Driver); |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
2950
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
########################################################################### |
|
40
|
|
|
|
|
|
|
#Library Modules # |
|
41
|
|
|
|
|
|
|
########################################################################### |
|
42
|
|
|
|
|
|
|
|
|
43
|
3
|
|
|
3
|
|
6184
|
use WWW::Mechanize; |
|
|
3
|
|
|
|
|
681594
|
|
|
|
3
|
|
|
|
|
154
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
########################################################################### |
|
46
|
|
|
|
|
|
|
#Constants # |
|
47
|
|
|
|
|
|
|
########################################################################### |
|
48
|
|
|
|
|
|
|
|
|
49
|
3
|
|
|
3
|
|
39
|
use constant AMAZON => 'http://www.amazon.fr/'; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
250
|
|
|
50
|
3
|
|
|
3
|
|
19
|
use constant SEARCH => 'http://www.amazon.fr/'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
2317
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
#-------------------------------------------------------------------------- |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
########################################################################### |
|
55
|
|
|
|
|
|
|
#Interface Functions # |
|
56
|
|
|
|
|
|
|
########################################################################### |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHODS |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=over 4 |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item C |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Creates a query string, then passes the appropriate form fields to the Amazon |
|
65
|
|
|
|
|
|
|
(FR) server. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
The returned page should be the correct catalog page for that ISBN. If not the |
|
68
|
|
|
|
|
|
|
function returns zero and allows the next driver in the chain to have a go. If |
|
69
|
|
|
|
|
|
|
a valid page is returned, the following fields are returned via the book hash: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
isbn |
|
72
|
|
|
|
|
|
|
author |
|
73
|
|
|
|
|
|
|
title |
|
74
|
|
|
|
|
|
|
book_link |
|
75
|
|
|
|
|
|
|
thumb_link |
|
76
|
|
|
|
|
|
|
image_link |
|
77
|
|
|
|
|
|
|
pubdate |
|
78
|
|
|
|
|
|
|
publisher |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
The book_link, thumb_link and image_link refer back to the Amazon (FR) website. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub search { |
|
85
|
2
|
|
|
2
|
1
|
6551
|
my $self = shift; |
|
86
|
2
|
|
|
|
|
4
|
my $isbn = shift; |
|
87
|
2
|
|
|
|
|
13
|
$self->found(0); |
|
88
|
2
|
|
|
|
|
45
|
$self->book(undef); |
|
89
|
|
|
|
|
|
|
|
|
90
|
2
|
|
|
|
|
36
|
my $mechanize = WWW::Mechanize->new(); |
|
91
|
2
|
|
|
|
|
1311575
|
$mechanize->get( SEARCH ); |
|
92
|
2
|
50
|
|
|
|
1408110
|
return $self->handler('Error loading amazon.fr form web page (unreachable?)') |
|
93
|
|
|
|
|
|
|
unless($mechanize->success()); |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
|
96
|
2
|
|
|
|
|
67
|
my ($index,$input) = (0,0); |
|
97
|
|
|
|
|
|
|
|
|
98
|
2
|
50
|
|
|
|
14
|
$mechanize->form_name('site-search') |
|
99
|
|
|
|
|
|
|
or return $self->handler('Error parsing amazon.fr form'); |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
|
|
|
|
239067
|
my $keyword; |
|
102
|
|
|
|
|
|
|
# This is to search for books |
|
103
|
|
|
|
|
|
|
# ( |
|
104
|
2
|
|
|
|
|
7
|
$keyword ='search-alias=stripbooks'; |
|
105
|
2
|
|
|
|
|
12
|
$mechanize->set_fields( |
|
106
|
|
|
|
|
|
|
'field-keywords' => $isbn, |
|
107
|
|
|
|
|
|
|
'url' => $keyword |
|
108
|
|
|
|
|
|
|
); |
|
109
|
2
|
|
|
|
|
681
|
$mechanize->submit(); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
|
112
|
2
|
50
|
|
|
|
1317406
|
return $self->handler('Error about form submission (form changed?)') |
|
113
|
|
|
|
|
|
|
unless($mechanize->success()); |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
|
116
|
2
|
|
|
|
|
71
|
my $content=$mechanize->content(); |
|
117
|
2
|
|
|
|
|
71
|
my ($con,$thumb, $image, $pub); |
|
118
|
|
|
|
|
|
|
|
|
119
|
2
|
50
|
|
|
|
98373108
|
if( |
|
120
|
0
|
|
|
|
|
0
|
$content =~ s{ |
|
121
|
|
|
|
|
|
|
.* |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
.* |
|
124
|
|
|
|
|
|
|
|