Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

SOLVED: Get a list attributes from a given tag in Mojo::DOM

by igoryonya (Pilgrim)
on Jun 13, 2024 at 10:31 UTC ( [id://11159945]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/env perl
    use utf8;
    ...
    }
    
    say "Tags are:\n\t", Mojo::DOM->new($data)->find('a')->map(attr=>'href
    +')->uniq->sort->join("\n\t");
    
  2. or download this
    Mojo::DOM->new($data)->find('a')->map(attr=>'*')->join("\n\t");
    
  3. or download this
    my %attrs = "Tags are:\n\t", Mojo::DOM->new($data)->attr;
    map{ print "(%s)/(%s)\n", $_, $attrs{$_} } sort keys %attrs;
    
  4. or download this
    my $dom = Mojo::DOM->new($data);
    map{ say }  $dom->find('a')->first;
    my $attrs = $dom->find('a')->first->attr;
    map{ printf "(%s)/(%s)\n", $_, $attrs->{$_} } sort keys %$attrs;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11159945]
Approved by Corion
Front-paged by cavac
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-09-14 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.