in reply to Extracting a substring of N chars ignoring embedded HTML
Printsuse HTML::TokeParser::Simple; my $doc = qq(story on GettingIt about <a href="http://ss.gettingit.com +/cgi-bin/gx.cgi/AppLogic+FTContentServer?GXHC_gx_session_id_FutureTen +seContentServer=7f12a816fa48a5b9&pagename=FutureTense/Demos/GI/Templa +tes/Article_View&parm1=A1545-1999Oct12&topframe=true">hacking polls</ +a>. Contrary to what the article says, Time is <b>not</b> checking fo +r multiple votes on <a href="javascript:document.timedigital.submit() +;">their poll</a>. And I'm happy to report that despite the fact that + my cheater scripts aren't running, I'm still beating Bill Gates.); my $doc2; my $total = 0; my $p = HTML::TokeParser::Simple->new( \$doc ); while ( my $token = $p->get_token ) { if ($token->is_text) { if (length($token->return_text) + $total <= 200) { $doc2 .= $token->return_text; $total += length($token->return_text); } else { for (split / /, $token->return_text) { if ($total + length($_) <= 200) { $doc2 .= $_ . ' '; $total += length($_) + 1; } else { last; } } chop($doc2) if $doc2 =~ /\s$/; } } else { $doc2 .= $token->as_is; } } print $doc2;
HTHstory on GettingIt about <a href="http://ss.gettingit.com/cgi-bin/gx.c +gi/AppLogi c+FTContentServer?GXHC_gx_session_id_FutureTenseContentServer=7f12a816 +fa48a5b9&p agename=FutureTense/Demos/GI/Templates/Article_View&parm1=A1545-1999Oc +t12&topfra me=true">hacking polls</a>. Contrary to what the article says, Time is + <b>not</b > checking for multiple votes on <a href="javascript:document.timedigi +tal.submit ();">their poll</a>. And I'm happy to report that despite the fact tha +t my cheat er scripts
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Extracting a substring of N chars ignoring embedded HTML
by graff (Chancellor) on Jan 12, 2003 at 04:29 UTC | |
by LTjake (Prior) on Jan 12, 2003 at 14:25 UTC | |
|
Re: Re: Extracting a substring of N chars ignoring embedded HTML
by FamousLongAgo (Friar) on Jan 11, 2003 at 23:46 UTC |