getDiskPrices = async (inputs) => {
const url = inputProxy.cors + formDiskPriceURL(inputs)
try {
const response = await fetch(url, fetchConfig);
if (!response.ok) throw new Error(`HTTP error: ${response.status}`);
const text = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(text, 'text/html');
const disks = [...doc.querySelectorAll('tr.disk')].map(row => ({
pricePerGB: row.querySelector('.price-per-gb')?.textContent.trim() || null,
pricePerTB: row.querySelector('.price-per-tb')?.textContent.trim() || null,
totalPrice: row.children[2]?.textContent.trim() || null,
capacity: row.children[3]?.textContent.trim() || null,
type: row.children[5]?.textContent.trim() || null,
interface: row.children[6]?.textContent.trim() || null,
condition: row.children[7]?.textContent.trim() || null,
name: row.querySelector('.name a')?.textContent.trim() || null,
link: row.querySelector('.name a')?.href || null
}));
return disks;
} catch (error) {
console.error('Error:', error);
return [];
}
}