http://qs321.pair.com?node_id=895706


in reply to Formating a HTML document to show certain text.

  1. $ lwp-download http://www.imreportcard.com/products/the-elevation-group
    Saving to 'the-elevation-group.htm'...
    35.2 KB received
     

  2. $ perl htmltreexpather.pl the-elevation-group.htm 2>NUL |grep -A3 "^Product Description$" Product Description
    /html/body/div/div[3]/div/div/div[6]
    //div[@id='leftColTop']/div[6]
    //div[@id='leftColTop']/div[@class='heading']
     

  3. use HTML::TreeBuilder::XPath; my $tree= HTML::TreeBuilder::XPath->new; $tree->parse_file( "the-elevation-group.htm"); for my $n( $tree->findnodes( q#//div[@id='leftColTop']/div[@class='heading']# ) ){ print $n->getValue, "\n"; } __END__ Product Description Detailed Overview Reputation Domain "Whois"
  4. repeat