2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by d5e5
0

I can't reproduce your error. The following script gets a title from a web page and prints it. The output looks OK on my computer.

#!/usr/bin/perl
use strict; 
use warnings; 

# define the subclass
package IdentityParse;
use base "HTML::Parser";
use LWP::Simple;
use Encode qw(encode decode);
my $printit = 0;

sub start {
    my ($self, $tag, $attr, $attrseq, $origtext) = @_;
    
    $printit = 1 if $tag eq 'title';
}

sub text {
    return unless $printit == 1;
    my ($self, $text) = @_;
    my $encoded_text = encode('UTF-8', $text);
    print $encoded_text;

}

sub end {
    my ($self, $tag, $origtext) = @_;

    $printit = 0 if $tag eq 'title';
}

my $p = new IdentityParse;
my $content = get 'http://greekcook.gr/tags/%CE%BA%CF%81%CE%B9%CE%B8%CE%B1%CF%81%CE%AC%CE%BA%CE%B9';
$p->parse($content);

Outputs Συνταγές : κριθαράκι

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.