title: How do I extract an HTML element based on its class?
body: <p>I'm just starting out in Perl, and wrote a simple script to do some web scraping. I'm using WWW::Mechanize and HTML::TreeBuilder to do most of the work, but I've run into some trouble. I have the following HTML:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;table class="winsTable"&gt;
      &lt;thead&gt;...&lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td class = "wins"&gt;15&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I know there are some modules that get data from tables, but this is a special case; not all the data I want is in a table. So, I tried:</p>
  
  <pre><code>my $tree = HTML::TreeBuilder-&gt;new_from_url( $url );
  my @data = $tree-&gt;find('td class = "wins"');
  </code></pre>
  
  <p>But <code>@data</code> returned empty. I know this method would work without the class name, because I've successfully parsed data with <code>$tree-&gt;find('strong')</code>. So, is there a module that can handle this type of HTML syntax? I scanned through the HTML::TreeBuilder documentation and didn't find anything that appeared to, but I could be wrong.</p>