title: cheerio - select multiples classes
body: <p>i post my question hope that someone can help me,
  i try to grab all the links which have an attribute for a bot
  using cheerio i make a request to a url and it retrieve me a html page in a string.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;test&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;a href="google.fr" class="test"&gt;&lt;/a&gt;
      &lt;a href="yahoo.com" class="test"&gt;&lt;/a&gt;
      &lt;a href="amazon.fr" class="test"&gt;&lt;/a&gt;
      &lt;a href="linux.org" class="test"&gt;&lt;/a&gt;
      &lt;a href="facebook.com" class="no_select"&gt;&lt;/a&gt;
      &lt;a href="twitter.com" class="no_select"&gt;&lt;/a&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>i tried things like this</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const cheerio = require('cheerio');
  const page = `&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;a href="google.fr" class="test"&gt;&lt;/a&gt;
  &lt;a href="yahoo.com" class="test"&gt;&lt;/a&gt;
  &lt;a href="amazon.fr" class="test"&gt;&lt;/a&gt;
  &lt;a href="linux.org" class="test"&gt;&lt;/a&gt;
  &lt;a href="facebook.com" class="no_select"&gt;&lt;/a&gt;
  &lt;a href="twitter.com" class="no_select"&gt;&lt;/a&gt;
  &lt;/body&gt;
  &lt;/html&gt;`
  const $ = cheerio.load(page)
  const links = $('.test').each( (index, elem) =&gt;{
   console.log(elem);
  });
  console.log(links);</code></pre>
  </div>
  </div>
  </p>
  
  <p>but without a great success.</p>
  
  <p>I'm looking for a solution to retrieve an array which each element is the href attribute ok a link which have the test class using cheerio.</p>
  
  <p>Thanks for you're help =)</p>