Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


I am trying to extract the following text from HTML page using the following code, but my code fails..

Budget - $25,000,00
Gross(worldwide) - $58,500,00

#!/usr/bin/perl use HTML::TokeParser; my $content = <<HTML; <h5>Budget</h5> $25,000,000 (estimated)<br/> <br/> <h5>Opening Weekend</h5> $727,327 (USA) (<a href="/date/09-25/">25 September</a> <a href="/year +/1994/">1994</a>) (33 Screens)<br/> <br/> <h5>Gross</h5> $28,341,469 (USA) (<a href="/date/08-05/">5 August</a> <a href="/year/ +2012/">2012</a>)<br/>&#163;2,344,349 (UK) (<a href="/date/05-18/">18 +May</a> <a href="/year/1995/">1995</a>)<br/>&#163;1,732,123 (UK) (<a +href="/date/04-16/">16 April</a> <a href="/year/1995/">1995</a>)<br/> +$58,500,000 (Worldwide)<br/>$555,480 (Belgium)<br/>ESP 637,291,985 (S +pain)<br/> <br/> <h5>Admissions</h5> 82,890 (Belgium)<br/>163,594 (France) (<a href="/date/03-28/">28 March +</a> <a href="/year/1995/">1995</a>)<br/>410,811 (Germany) (<a href=" +/date/12-31/">31 December</a> <a href="/year/1995/">1995</a>)<br/>1,2 +45,604 (Spain)<br/> <br/> <h5>Filming Dates</h5> <a href="/date/06-16/">16 June</a> <a href="/year/1993/">1993</a>&nbsp +;-&nbsp;<a href="/date/09-10/">10 September</a> <a href="/year/1993/" +>1993</a><br/> <br/> HTML my $description = ""; my $parser = HTML::TokeParser->new(\$content) || die "Can't open: $!"; while (my $token = $tp->get_tag("h5")) { my $text = $parser->get_text(); last if $text =~ /budget/i; }

In reply to HTML::TokeParser - extract values between tags by doubledecker

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2022-01-26 06:40 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (69 votes). Check out past polls.