Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

How to read onclick properties on row of a table using HTML::Table::Extractor

by ckj (Chaplain)
on Aug 27, 2012 at 03:15 UTC ( #989907=perlquestion: print w/ replies, xml ) Need Help??
ckj has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, My perl code is something like this and it is also working fine:
use HTML::TableExtract; $te = HTML::TableExtract->new( headers => [qw(Date Price Comments)] ) +; $te->parse($html_string); # Examine all matching tables foreach $ts ($te->tables) { print "Table (", join(',', $ts->coords), "):\n"; foreach $row ($ts->rows) { print join(',', @$row), "\n"; } }
My table is something like this:
<table> <tr><td>Date</td><td>Price</td><td>Comments</th></tr> <tr onclcick="dkfjskdjfskfd"><td>21/9</td><td>2324</td><td>abc</td></t +r> <tr onclcick="dkfjskdjfskfd1"><td>21/9</td><td>2324</td><td>abasdasc</ +td></tr> <tr onclcick="dkfjskdjfskfdsdfsdf2"><td>21/9</td><td>2324</td><td>absa +dsadsc</td></tr> </table>
Now the data are coming fine, but I want to read the onclick properties also for each row. so output should be something like this :
dkfjskdjfskfd, 21/9, 2324, abc dkfjskdjfskfd1, 21/9, 2324, abasdasc dkfjskdjfskfdsdfsdf2, 21/9, 2324, absadsadsc
Please advise to include the row properties through HTML::Table::Extract

Comment on How to read onclick properties on row of a table using HTML::Table::Extractor
Select or Download Code
Re: How to read onclick properties on row of a table using HTML::Table::Extractor
by Anonymous Monk on Aug 27, 2012 at 06:08 UTC

    Please advise to include the row properties through HTML::Table::Extract

    There is no such module

    In any case, I would ditch the module, use the DOM

    There is probably an example in the distribution (in the test directory)

Re: How to read onclick properties on row of a table using HTML::Table::Extractor
by Anonymous Monk on Aug 28, 2012 at 07:57 UTC
Re: How to read onclick properties on row of a table using HTML::Table::Extractor ( DOM approach using xsh)
by Anonymous Monk on Aug 28, 2012 at 09:37 UTC

    xsh is kinda hard to learn but this does it :)

    $ xsh -q < table.xsh /body/table ,Date,Price,Comments dkfjskdjfskfd,21/9,2324,abc dkfjskdjfskfd1,21/9,2324,abasdasc dkfjskdjfskfdsdfsdf2,21/9,2324,absadsadsc $ cat table.xsh open "table.html"; for //table { echo; pwd; echo; for ./tr { my $first = @onclcick; $first ||=""; echo xsh:join(",", $first, ./td ); }; echo; }; echo;

    Naturally it doesn't handle rowspan/colspan or tbodys

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://989907]
Approved by sundialsvc4
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-12-18 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (42 votes), past polls