简体   繁体   中英

JS Puppeteer - How to scrape a table

I am not too knowledgeable with Javascript or Puppeteer and I was wondering how to scrape the following table:

我想刮的桌子

I want to scrape everything within body which are all <tr>...</tr> which have <td class="className">...</td> 在此处输入图片说明

Any solutions?

let text = await page.evaluate (() => document.querySelector('tbody').innerText)

That might look something like:

await page.evaluate (() => {
  return [...document.querySelectorAll('.tbrdr tbody tr')].map(tr => {
    return [...tr.querySelectorAll('td.className')].map(td => td.innerText)
  })
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM