1

良い一日、

HTMLでタグのテキストをどのように印刷しますWWW::Mechanize::Firefoxか?

私が試してみました:

    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');

私はしたくないことを覚えています{innerhtml}が、それはうまくいきます。

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

上記の行は機能しますが、出力は単に複数です/n

4

4 に答える 4

1

私が持っている唯一の解決策は、使用することです:

my $element = $mech->selector('td.dataCell');

my $string = $element->{innerHTML};

そして、それぞれの中でhtmlをフォーマットしますdataCell

于 2013-03-29T14:28:05.433 に答える
1

私はするだろう:

print $mech->xpath('//td[@class="dataCell"]/text()');

式を使用する

于 2013-03-27T22:16:05.967 に答える
0

また:

$element->{textContent};

また

$element->{innerText};

動作します。

于 2016-09-12T03:55:48.390 に答える