htmlperlweb-scrapingwww-mechanizewww-mechanize-firefox

WWW::Mechanize::Firefox How do you extract the text within HTML element tags?


Good Day,

How do you print the text of an HTML tag with WWW::Mechanize::Firefox?

I have tried:

    print $_->text, '/n' for $mech->selector('td.dataCell');

    print $_->text(), '/n' for $mech->selector('td.dataCell');


    print $_->{text}, '/n' for $mech->selector('td.dataCell');

    print $_->content, '/n' for $mech->selector('td.dataCell');

Remember I do not want {innerhtml}, but that does work btw.

print $_->{text}, '/n' for $mech->selector('td.dataCell');

The above line does work, but output is just multiple /n


Solution

  • The only solution I have is to use:

    my $element = $mech->selector('td.dataCell');
    
    my $string = $element->{innerHTML};
    

    And then formatting the html within each dataCell