1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
use 5.014; use HTML::Element; use HTML::TreeBuilder; use HTML::Entities; my $doc; use FileHandle; my $InputDatei = *DATA; { local $/ = undef; $doc = <$InputDatei>; } close $InputDatei; my $tree = HTML::TreeBuilder->new_from_content($doc); my $Foto = $tree->look_down( 'class', 'photo' ); say $Foto->as_HTML(); say "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; $Foto = $Foto->all_attr(); use Data::Dumper; say Dumper($Foto); __DATA__ <!DOCTYPE html> <head> <title>Spinatb?chen auf Lachscreme - BRIGITTE.de</title> </head> <body> <div class="headerElement info"> <div class="headerElement img"> <img class="photo" alt="Spinatb孬chen auf Lachscreme" width="200" height="200" src="http://img1.brigitte.de/thumbnails/rezepte/hauptgericht/fischmeeresfruechte/413ab/200/spinatbaellchen-auf-lachscreme.jpg?cache=183809651" /><br />© Knut Koops </div> <div class="meta print"> <div class="bewertungsanzeige"> </div> <h1 class="fn title">Spinatb孬chen auf Lachscreme</h1> <div class="recipeContent"> <span class="published"><span class="value-title" title="2011-07-28"></span></span> einfach </div> </div> </div> </body> </html> __END__ http://www.brigitte.de/rezepte/rezepte/spinatbaellchen_auf_lachscreme?print=1
Quote$h->all_attr()
Returns all this element's attributes and values, as key-value pairs