Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML::TableExtract question

Status
Not open for further replies.

kaancho12

Technical User
Feb 22, 2005
191
hi,
in this example of HTML::TableExtract how can i assign a table header that has space in its name- for example "Space Header" .

use HTML::TableExtract;
$te = HTML::TableExtract->new( headers => [qw(Date Price Cost)] );
$te->parse($html_string);

# Examine all matching tables
foreach $ts ($te->table_states) {
print "Table (", join(',', $ts->coords), "):\n";
foreach $row ($ts->rows) {
print join(',', @$row), "\n";
}
}

thanks
 
solved that part of it....
but here's another question:
i have a html table that i need to parse. The HTML table is like this:
---------------------------------------------------
| Name | Tag Price | Availability |
---------------------------------------------------
|Prod A |Table1 W/O header| Yes |
----------------------------------------------------
|Prod B |Table2 W/O header| Yes |
----------------------------------------------------
|Prod C |Table3 W/O header| No |
----------------------------------------------------

I need the information under the table header "Tag Price". I can get to the information there with:
$te = HTML::TableExtract->new( headers => [qw(Tag)] );
$te->parse($mech->content);
# Examine all matching tables
foreach $ts ($te->table_states) {
foreach $row ($ts->rows) {
foreach $array_element(@$row)
{
print $array_element, "\n";
}
}
}
What i still need to do is:
-I cannot see the contents of the table(Table1 W/O header etc..) and its values.
-Some of the table (Table1 W/O header etc...) have links which i would like to extract from the attributes...but the table returned seems to have all the HTML stripped off when just doing the regular TableExtract....
For example if this is contained in a row: <TD><a href="test.html" onmouseover="do this">test</a></TD>
can i do TableExtract with only the table values stripped off. I guess reg. exp. will be helpful but this page is lot complicated than just the table above and i am better off using Table::Extract.
thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top