1 # (c) 2007 by Ralf Ertzinger <ralf@camperquake.de>
2 # licensed under GNU GPL v2
4 # Grabber for german-bash.org
9 @ISA = qw(GrabberBase);
11 use LWP::Simple qw(!get);
20 my $self = $class->SUPER::new();
22 $self->{'NAME'} = 'ibash.de';
23 $self->{'PATTERNS'} = ['(http://(?:[-a-zA-Z0-9_.]+\.)*ibash.de/zitat_(\d+)\.html)'];
26 $self->_prepare_parameters();
43 $metadata->{'URL'} = $url;
44 $metadata->{'ID'} = $2;
45 $metadata->{'TYPE'} = 'quote';
46 $metadata->{'SOURCE'} = $self->{'NAME'};
47 $metadata->{'CONTENT'} = undef;
49 # Get the HTML file containing the quote
50 unless(defined($content = LWP::Simple::get(sprintf('http://www.ibash.de/zitat_%s.html', $2)))) {
51 $self->error('Could not download quote');
55 $p = HTML::TokeParser->new(\$content);
57 while ($t = $p->get_tag('td')) {
58 if (exists($t->[1]->{'class'}) && ($t->[1]->{'class'} eq 'quote')) {
59 $metadata->{'CONTENT'} = $p->get_text('/td');
60 Encode::from_to($metadata->{'CONTENT'}, 'iso-8859-1', 'utf8');
64 unless(defined($metadata->{'CONTENT'})) {
65 $self->error('Could not extract quote content');