title: How to grab span text values with Puppeteer
body: <p>I'm using Puppeteer to scrape <a href="http://quotes.toscrape.com/" rel="nofollow noreferrer">this website</a>. I want to loop over each quote and create an array of objects with 3 values each: quote, by, category. I'm having a hard time pulling the span text out of each div. Here's what I have so far:</p>
  
  <pre><code>        const quotes = await page.evaluate(() =&gt; {
          const grabFromDiv = (div, classname) =&gt; div 
          .querySelector(`div.${classname}`)
          .innerText 
          .trim()
  
          //our selectors 
          const quote_selector = 'div.quote'
  
          //store our data in an array of objects 
          const data = []
  
          //get all quotes
          const quoteDivs = document.querySelectorAll(quote_selector)
  
          //loop over each quote block, creating objects 
          for (const span of quoteDivs) {
              data.push({
                  quote: grabFromDiv(span, 'text'),
                  by: grabFromDiv(small, 'author'),
                  category: grabFromDiv(a, 'tag'),
              })
          }
          //send the data back into the quotes variable
          return data 
      })
  </code></pre>
  
  <p>As of now, it is returning an array of these objects:</p>
  
  <pre><code>  {
       "quote": null,
       "by": null,
       "category": null
    }
  </code></pre>