Skip to content Skip to sidebar Skip to footer

Html::tableextract: Applying The Right Attribs To Specify The Attributes Of Interest

I tried to run the following Perl script on the HTML further below. My problem is how to define the correct hash reference, with attribs that specify attributes of interest within

Solution 1:

You need to provide something that uniquely identifies the table in question. This can be the content of its headers or the HTML attributes. In this case, there is only one table in the document, so you don't even need to do that. But, if I were to provide anything to the constructor, I would provide the class of the table.

Also, I do not think you want the columns of the table. The first column of this table consists of labels and the second column consists of values. To get the labels and values at the same time, you should process the table row-by-row.

#!/usr/bin/perluse strict; use warnings;
use HTML::TableExtract;
use YAML;

my $te = HTML::TableExtract->new(
    attribs => { class =>'bp_result_tab_info' },
);

$te->parse_file('t.html');

formy $table ( $te->tables ) {
    print Dump $table->columns;
}

Output:

---
- 'data_one '
- data_two
- official_description
- name of the street
- number and town
- telefon
- fax
- e-mail-adresse
- internet-site
- á
- á
- number of indidviduals
- á
---
- ~
- "á116439\r\n  "
- 'the name '
- champs elysee
- ' 75000 paris '
- "á000241 49321\r\n"
- "á000241 4093287\r\n"
- "á1222216439@site.org\r\n"
- áhttp://www.thesite.org
- the department
- ~
- á192
- ~

Finally, a word of advice: It is clear that you do not have much of an understanding of Perl (or HTML for that matter). It would be better for you to try to learn some of the basics first. This way, all you are doing is incorrectly copying and pasting code from one answer into another and not learning anything.

Post a Comment for "Html::tableextract: Applying The Right Attribs To Specify The Attributes Of Interest"