perl HTML::TokeParser

学习HTML::TokeParser,此模块比HTML:吐舌笑脸arser简单很多。

看代码:

#! /usr/local/bin/perl
use LWP::Simple;
use Data::Dumper;
use HTML::TokeParser;
use Encode;

my $content = get("http://www.sina.com.cn/");
Encode::_utf8_off($content);
open FH,">","1.html";
print FH $content;
system("dos2unix ./1.html 2> /dev/null");

my $p = HTML::TokeParser->new('1.html',
);

while( my $token = $p->get_tag("tr")){
        my $text = $p->get_trimmed_text("tr","/tr");
        print $text."\n";
}

你可能感兴趣的:(html,职场,perl,休闲)