
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 19, 2021 09:05 AM
I’m not sure if this would be a script, but I have a table full of URLs and I want to query the ‘page title’ for that URL and return it to populate in another field ‘Page title’. Does anyone know if this is possible and if so what script I should run?
Thanks
1 Reply 1

Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 04, 2024 09:12 AM
For anyone else searching, here is some code that gets the title from a webpage to populate a title field
// Define the table names
const urlTableName = "URLs";
let urlTable = base.getTable(urlTableName);
// Prompt the user to select the current link record
let record = await input.recordAsync('Pick a link record', urlTable);
// Check if a record was selected
if (!record) {
output.text("No record selected. Please select a record to run the script.");
} else {
const url = record.getCellValue('URL');
const response = await remoteFetchAsync(url + "/");
const text = await response.text();
const title = text.match(/<title>(.*?)<\/title>/)[1];
await urlTable.updateRecordAsync(record.id, {
'Title': title
});
console.log(`Updated record ${record.id} with title: ${title}`);
}
