The following bit of code is intended for a Script block to pull data into airtable it was written by chatgpt
I cant make this work for the life of me
async function updateRDAPData() {
let table = base.getTable('Wucy'); // Correct table name
let query = await table.selectRecordsAsync({
fields: ['Value'] // This field contains the full RDAP URLs
});
for (const record of query.records) {
let url = record.getCellValue('Value'); // Get the RDAP URL from the record
if (!url) {
console.log(`Skipping record ${record.id} because no URL is present.`);
continue;
}
console.log(`Fetching RDAP data from URL: ${url}`);
try {
let response = await fetch(url);
if (!response.ok) {
console.error(`HTTP Error: Failed to fetch RDAP data from URL ${url}: ${response.status} ${response.statusText}`);
continue;
}
let data = await response.json();
// Extract necessary details from RDAP response
let networkHandle = data.handle || "No network handle found";
let networkName = data.name || "No network name found";
let entityDetails = (data.entities && data.entities.length > 0) ?
data.entities.map(entity => `Handle: ${entity.handle}, Roles: ${entity.roles.join(', ')}`).join('\n') :
"No entities found";
// Update Airtable records with the extracted data
await table.updateRecordAsync(record.id, {
'Network Handle': networkHandle, // Make sure these field names are correct
'Name': networkName, // and exist in your table
'Entity Details': entityDetails // Create this field if you need to store entity information
});
} catch (error) {
console.error(`Error processing URL ${url} for record ${record.id}:`, error);
}
}
console.log('RDAP data update completed.');
}
updateRDAPData();