SOURCE

function htmlToNode(htmlString) {
    const tempDiv = document.createElement('div')
    tempDiv.innerHTML = htmlString.trim()
    return tempDiv
}

function createVirtualElement(dom) {
    const tempDiv = document.createElement('div')
    tempDiv.innerHTML = dom
    return tempDiv
}
function removeDuplicateTableWrappers(dom) {
    const cloneDom = dom.cloneNode(true)
    function maxDescendantsNode(nodeList) {
        let maxDescendants = 0;
        let maxDescendantsNode = null;

        for (const currentNode of nodeList) {
            const descendants = countDescendants(currentNode);
            if (descendants > maxDescendants) {
                maxDescendants = descendants;
                maxDescendantsNode = currentNode;
            }
        }

        return maxDescendantsNode;

        function countDescendants(node) {
            let count = 0;
            for (const childNode of node.childNodes) {
                if (childNode.nodeType === Node.ELEMENT_NODE) {
                    count += countDescendants(childNode);
                } else if (childNode.nodeType === Node.TEXT_NODE && !childNode.data.trim().length) {
                    // ignore whitespace text nodes
                } else {
                    count++;
                }
            }
            return count;
        }
    };

    const divs = cloneDom.querySelectorAll('div.use-for-table-wrapper')
    const maxChildrenDiv = maxDescendantsNode(divs)
    const table = maxChildrenDiv.querySelector('table')
    const cloneTable = table.cloneNode(true)
    maxChildrenDiv.innerHTML = ''
    maxChildrenDiv.appendChild(cloneTable)
    console.log(maxChildrenDiv)
}



const htmlString = `<p style="text-indent: 32pt; line-height: 1.75em;">为规范房地产中介市场,促进行业健康发展,依据《房地产经纪管理办法》规定,现将宿州市房地产中介机构备案信息变更内容(2021)第三批进行公示:</p><div class="use-for-blank" style="height: 15px;">&nbsp;</div><p style="line-height: 1.75em; text-indent: 2em;">宿州市家天下房产经纪有限公司</p><div class="use-for-blank" style="height: 15px;">&nbsp;</div><p style="line-height: 1.75em; text-indent: 2em;">变更事项: 注册资金变更、经纪人信息变更</p><div class="use-for-blank" style="height: 15px;">&nbsp;</div><div style="overflow: auto;"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><div class="use-for-table-wrapper" style="overflow:auto"><table style="border-collapse: collapse; border: none;" border="1" width="990" cellspacing="0" cellpadding="0" align="left"><tbody style=""><tr style=""><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">机构名称</span></strong></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">法定代表人</span></strong></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">注册资本</span></strong></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">经营地址</span></strong></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">房地产经纪人</span></strong></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">身份证号</span></strong></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><strong style=""><span style="font-family: 宋体; display: block; line-height: 1.75em;">管理号</span></strong></p></td></tr><tr style=""><td style="padding: 5px; text-align: center;" rowspan="3" width=""><p style=""><span style="font-size: 14pt; font-family: 仿宋; color: black; display: block; line-height: 1.75em;">宿州市家天下房产经纪有限公司</span></p></td><td style="padding: 5px; text-align: center;" rowspan="3" width=""><p style="text-align: center;"><span style="font-size: 12pt; font-family: 宋体; color: black; display: block; line-height: 1.75em;">李彩云</span></p></td><td style="padding: 5px; text-align: center;" rowspan="3" width=""><p style="text-align: center;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">肆佰零捌万壹仟柒佰圆整</span></p></td><td style="padding: 5px; text-align: center;" rowspan="3" width=""><p style="text-align: left;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">宿州市银河三路宿州碧桂园3栋105号</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 12pt; font-family: 宋体; color: black; display: block; line-height: 1.75em;">李彩云</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 12pt; font-family: 宋体; display: block; line-height: 1.75em;">342201******177226</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">30620201034200000275</span></p></td></tr><tr style=""><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">周琛</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 12pt; font-family: 宋体; display: block; line-height: 1.75em;">342201******250814</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">30620201034200000968</span></p></td></tr><tr style=""><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">孟俊全</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 12pt; font-family: 宋体; display: block; line-height: 1.75em;">342201******204418</span></p></td><td style="padding: 5px; text-align: center;" width=""><p style="text-align: center;"><span style="font-size: 11pt; font-family: 宋体; display: block; line-height: 1.75em;">30620191034200000292</span></p></td></tr></tbody></table></div></div></div></div></div></div></div></div></div></div><div class="use-for-blank" style="height: 15px;">&nbsp;</div><p style="line-height: 1.75em; text-align: right;">监督电话: 0557-3956095、0557-3025848</p><p style="text-align: right;"><span style="text-indent: 110pt; line-height: 1.75em; display: inherit;">宿州市房产管理服务中心</span></p><p style="text-align: right;"><span style="text-indent: 80pt; line-height: 1.75em; display: inherit;">2021年7月21日</span></p>`
const nodeh = htmlToNode(htmlString)
// console.log(nodeh)
const processedHtml = removeDuplicateTableWrappers(nodeh);
// console.log(processedHtml);
console 命令行工具 X clear

                    
>
console