Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to find a table with Web::Scraper based on cell values?
    primarykey
    data
    text
    <p>Want process a several html pages with tables.</p> <p>The pages:</p> <ul> <li>contains several classless tables, the only way how to identify the correct one</li> <li>the needed table has in the 1st cell value "<em>Content</em>"</li> </ul> <p>Question: How to find a correct table based on its cell value with Web::Scrape or Scrappy or another tool?</p> <p>Example code:</p> <pre><code>#!/usr/bin/env perl use 5.014; use warnings; use Web::Scraper; use YAML; my $html = do { local $/; &lt;DATA&gt; }; my $table = scraper { #the easy way - table with class, or id or any attribute #process 'table.xxx &gt; tr', 'rows[]' =&gt; scraper { #unfortunately, the table hasn't class='xxx', so :( process 'NEED_HELP_HERE &gt; tr', 'rows[]' =&gt; scraper { process 'th', 'header' =&gt; 'TEXT'; process 'td', 'cols[]' =&gt; 'TEXT'; }; }; my $result = $table-&gt;scrape( $html ); say Dump($result); __DATA__ &lt;head&gt;&lt;title&gt;title&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;table&gt;&lt;tr&gt;&lt;th class="inverted"&gt;header&lt;/th&gt;&lt;td&gt;value&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; &lt;!-- here are several another tables (different count) --&gt; &lt;table&gt; &lt;!-- would be easy with some class="xxx" --&gt; &lt;tr&gt; &lt;th class="inverted"&gt;Content&lt;/th&gt; &lt;!-- Need this table - 1st cell == "Content" --&gt; &lt;td class="inverted"&gt;col-1&lt;/td&gt; &lt;td class="inverted"&gt;col-n&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;Date&lt;/th&gt; &lt;td&gt;2012&lt;/td&gt; &lt;td&gt;2001&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th&gt;Banana&lt;/th&gt; &lt;td&gt;val-1&lt;/td&gt; &lt;td&gt;val-n&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload