Hello,

I wanna extract : - text from date, title, cat and lieu classes - anchors with Mojo::Dom but I am not able to do it :

Is it possible to get data like this : for each anchor into "ret" div, get (anchors, date elements, title, cat and lieu)

Thanks a lot

use Mojo::DOM; my $dom = Mojo::DOM->new(<<'HTML'); <div class="ret"> <a href="blabla.com/1234" title="Text 1"> <div class="rtm"> <div class="date"> <div>22</div> <div>mai</div> <div>19:52</div> </div> <div class="image"> <div class="imageclass-and-nb"><im +g src="blabla.com/img1234" alt="Text 1"></div> </div> <div class="all"> <h2 class="title">Text 1 Title</h2> <div class="cat">Blue</div> <div class="lieu">Dourdan</div> </div> </div> </a> <a href="blabla.com/1212" title="Text 2"> <div class="rtm"> <div class="date"> <div>22</div> <div>mai</div> <div>11:55</div> </div> <div class="image"> <div class="imageclass"><img src=" +blabla.com/img1212" alt="Text 2"></div> </div> <div class="detail"> <h2 class="title">Text 2 title</h2> <div class="cat">Blue</div> <div class="lieu">Champigny-sur-Marne< +/div> </div> </div> </a> </div> HTML print $dom->find('div.date')->map(sub{$_->children->each})->map(sub{$_ +->text})->each;

In reply to Mojo Dom extract by ribo75017

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.