X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=quotesite.git;a=blobdiff_plain;f=quotesite%2FiBashGrabber.pm;h=973d7219796668c6feea6acb5ad8557274522870;hp=04bd07d22b17f084b2e2111fa4805c2e236cb095;hb=4e748bf6684b36a73f73312c4c694dd6d5655e84;hpb=5ac855980b32d2995ad48b7a27cc28630306bc15 diff --git a/quotesite/iBashGrabber.pm b/quotesite/iBashGrabber.pm index 04bd07d..973d721 100644 --- a/quotesite/iBashGrabber.pm +++ b/quotesite/iBashGrabber.pm @@ -3,10 +3,10 @@ # # Grabber for german-bash.org -package iBashGrabber; +package quotesite::iBashGrabber; -use GrabberBase; -@ISA = qw(GrabberBase); +use quotesite::GrabberBase; +@ISA = qw(quotesite::GrabberBase); use LWP::Simple qw(!get); use HTML::TokeParser; @@ -28,6 +28,38 @@ sub new { return $self; } +sub __buildquote_line { + my $self = shift; + my $p = shift; + my $t; + my $data = ''; + + while ($t = $p->get_tag('td', '/tr')) { + if ($t->[0] eq '/tr') { + return $data; + } + if (exists($t->[1]->{'colspan'})) { + return ''; + } + $data .= $p->get_text('/td') + } +} + + +sub __buildquote_block { + my $self = shift; + my $p = shift; + my $t; + my $data; + + while ($t = $p->get_tag('tr','/table')) { + if ($t->[0] eq '/table') { + return $data; + } + $data .= $self->__buildquote_line($p) . "\n"; + } +} + sub _parse { my $self = shift; my $url = shift; @@ -56,7 +88,7 @@ sub _parse { while ($t = $p->get_tag('td')) { if (exists($t->[1]->{'class'}) && ($t->[1]->{'class'} eq 'quote')) { - $metadata->{'CONTENT'} = $p->get_text('/td'); + $metadata->{'CONTENT'} = $self->__buildquote_block($p); Encode::from_to($metadata->{'CONTENT'}, 'iso-8859-1', 'utf8'); } }