//Use in console of product page to get data in json. use online tools to convert it to yaml and upload in yaml field. // Select the specific table inside the div with id 'details_collapse_2' const table = document.querySelector('#details_collapse_2 .table-details tbody'); if (table) { const rows = table.querySelectorAll('tr'); const jsonData = {}; rows.forEach((row) => { // Extract the primary node title from the const primaryNode = row.querySelector('.tr-Head .row-ttl')?.textContent.trim(); if (primaryNode) { const items = row.querySelectorAll('.arw-item'); const nodeData = {}; items.forEach((item) => { const strongElement = item.querySelector('strong'); if (strongElement) { const key = strongElement.textContent.replace(':', '').trim(); const value = strongElement.nextSibling.textContent.trim(); nodeData[key] = value; } else { // Handle items without , e.g., "12 V VRLA" const value = item.textContent.trim(); if (!nodeData["Other"]) { nodeData["Other"] = []; } nodeData["Other"].push(value); } }); // If the "Other" node is present and not empty, convert primary node to array if (nodeData["Other"] && nodeData["Other"].length > 0) { jsonData[primaryNode] = nodeData["Other"].length === 1 ? [nodeData["Other"][0]] : nodeData["Other"]; delete nodeData["Other"]; // Remove the "Other" key } else { jsonData[primaryNode] = nodeData; } } }); // Log or return the JSON data console.log(JSON.stringify(jsonData, null, 2)); } else { console.error('Table not found inside #details_collapse_2'); }