Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks,
I am trying to retrieve the number of chars of a HTML page.
This is my first shot
#!/usr/local/bin/perl510 use warnings; use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new( ); $mech->agent_alias( 'Windows IE 6' ); my $url = 'http://www.somewhere.tld/'; $mech->get( $url ); $mech->success() or die "Get $url failed. " , $mech->response->status_line(); my $content = $mech->content(format => 'text'); my $len = length $content; print "Number of Chars: $len\n";
This gives a number of chars, that is close to the one M$-Office reports. (That is copy and paste the content of the same page opened in a browser to M$-Word.)
There's about 3 % difference.
Is there a better way to count the chars?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting chars in a HTML-page
by Perlbotics (Archbishop) on Aug 01, 2008 at 09:55 UTC | |
by ikegami (Patriarch) on Aug 01, 2008 at 10:51 UTC | |
|
Re: Counting chars in a HTML-page
by moritz (Cardinal) on Aug 01, 2008 at 09:48 UTC | |
|
Re: Counting chars in a HTML-page
by Corion (Patriarch) on Aug 01, 2008 at 09:57 UTC | |
|
Re: Counting chars in a HTML-page
by jethro (Monsignor) on Aug 01, 2008 at 10:31 UTC | |
|
Re: Counting chars in a HTML-page
by Illuminatus (Curate) on Aug 01, 2008 at 15:20 UTC | |
by Illuminatus (Curate) on Aug 01, 2008 at 20:28 UTC | |
|
Re: Counting chars in a HTML-page
by Anonymous Monk on Aug 01, 2008 at 11:41 UTC | |
by wol (Hermit) on Aug 01, 2008 at 14:11 UTC | |
|
Re: Counting chars in a HTML-page
by Ywleskvy (Initiate) on Aug 02, 2008 at 08:03 UTC | |
|
Re: Counting chars in a HTML-page
by Anonymous Monk on Aug 02, 2008 at 14:34 UTC | |
by Anonymous Monk on Aug 02, 2008 at 15:42 UTC | |
|
Re: Counting chars in a HTML-page
by jimX11 (Friar) on Aug 04, 2008 at 14:58 UTC |