この様な感じではいかがでしょうか。
html
1# テスト用HTML
2
3<html>
4
5<head>
6 <meta charset="UTF-8">
7 <title>Dev Server</title>
8</head>
9
10<body>
11 <table bordercolor="#00bfff">
12 <tr class="a">
13 <td>a1</td>
14 </tr>
15
16 <tr class="b">
17 <td>b1</td>
18 <td>b2</td>
19 </tr>
20
21 <tr class="c">
22 <td>c1</td>
23 <td>c2</td>
24 <td>c3</td>
25 </tr>
26 </table>
27</body>
28
29</html>
js
1# Main プログラム
2
3const puppeteer = require("puppeteer")
4
5const main = async () => {
6 const browser = await puppeteer.launch()
7 const page = await browser.newPage()
8
9 await page.goto("http://localhost:8080/")
10 // テスト用サーバーを起動しているので、ターゲットとなるURLにしてください。
11
12 const scrapingData = await page.evaluate(() => {
13 const dataList = []
14 const nodeList = document.querySelectorAll("tr")
15
16 nodeList.forEach(_node => {
17 const class_name = _node.className
18 const td_count = _node.innerHTML.match(/<td>/g).length
19
20 dataList.push(`${class_name}:${td_count}`)
21 })
22
23 return dataList
24 })
25
26 console.log(scrapingData)
27
28 browser.close()
29}
30
31main()
32
js
1# 実行結果
2
3[ 'a:1', 'b:2', 'c:3' ]
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。