const divs = document.querySelectorAll('div[class^="CanvasViewer__Container"]'); console.log("符合条件的 div 总数:", divs.length); const div = document.querySelector('div.printView > div:not(style)'); const div2 = Array.from(div.children).filter(el => el.tagName.toLowerCase() === 'div')[1]; const div2_1_1_1 = div2.querySelector('div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1)'); const count = Array.from(div2_1_1_1.children).filter(el => { return el.tagName.toLowerCase() === 'div' && el.hasAttribute('width') && el.hasAttribute('height'); }).length; console.log("div2.1.1.1 下的