Hi, for many hours I'm trying to extract needed text from a html format (by LWP::UserAgent). I need those text which are not in html tags: '< >' brackets. I wrote many codes, it seems my regexp not so good :-), I'll be happy if we can solve it togather, tnx...

example of html text: <h1>Volume Leaders</h1></div><div class="yfitabs"><div id="yfitt" class="yfitt"><ul><li class="on"><a href="/actives?e=us"><em>US</em></a></li><li><a href="/actives?e=o"><em>NASDAQ</em></a></li><li><a href="/actives?e=aq"><em>AMEX</em></a></li><li><a href="/actives?e=nq"><em class="last">NYSE</em></a></li></ul></div><div id="yfitp" class="yfitabsc"><table cellpadding="0" cellspacing="0"><thead><th class="first">Symbol</th><th class="second">Name</th><th>Last Trade</th><th>Change</th><th>Volume</th><th class="last">Related Info</th></thead><tbody><tr><td class="first"><b><a href="/q?s=BAC">BAC</a></b></td><td class="second name">Bank of America Corporation Com</td><td class="last_trade"><b><span id="yfs_l10_bac">8.06</span></b> <nobr><span id="yfs_t10_bac">Jul 3</span></nobr></td><td><span id="yfs_c10_bac"><img width="10" height="14" style="margin-right:-2px;" border="0" src="http://l.yimg.com/a/i/us/fi/03rd/up_g.gif" alt="Up"> <b style="color:#008800;">0.01</b></span> <span id="yfs_p20_bac"><b style="color:#008800;"> (0.12%)</b></span></td><td><span id="yfs_v00_bac">57,655,357</span></td><td class="last"><a href="/q/bc?s=BAC">Chart</a>, <a href="/q/pr?s=BAC">Profile</a>, <a href="/q?s=BAC">More</a></td></tr><tr><td class="first"><b><a href="/q?s=SIRI">SIRI</a></b></td><td class="second name">Sirius XM Radio Inc.</td><td class="last_trade"><b><span id="yfs_l10_siri">2.04</span></b> <nobr><span id="yfs_t10_siri">Jul 3</span></nobr></td><td><span id="yfs_c10_siri"><img width="10" height="14" style="margin-right:-2px;" border="0" src="http://l.yimg.com/a/i/us/fi/03rd/up_g.gif" alt="Up"> <b style="color:#008800;">0.06</b></span> <span id="yfs_p20_siri"><b style="color:#008800;"> (2.77%)</b></span></td><td><span id="yfs_v00_siri">53,607,894</span></td><td class="last"><a href="/q/bc?s=SIRI">Chart</a>, <a href="/q/pr?s=SIRI">Profile</a>, <a href="/q?s=SIRI">More</a></td></tr><tr><td class="first"><b><a href="/q?s=F">F</a></b></td><td class="second name">Ford Motor Company Common Stock</td><td class="last_trade"><b> EXAMPLE OF CODE:
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common qw(GET); my $ua = LWP::UserAgent->new; # Define user agent type $ua->agent('MyApp/0.1 '); # Request object my $req = GET 'http://finance.yahoo.com/actives?e=us'; # Make the request my $res = $ua->request($req); #my @con = $res->content; $res->content =~ /(<div class="yfitbg tbtabs">)(<h1>Volume Leaders.*)( +Get a)/s; my $cont = $2; print $cont, "\n"; exit 0;

In reply to regexp solutions by programmer.perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.