This guide will walk you through creating a basic alternative to Claygent using Google Sheets and Apps Script. Our tool will take a list of company names, search for their contact pages, and attempt to extract email addresses from those pages.
Code.gs fileAdd the following function to your Apps Script:
function searchContactPage(companyName) {
const API_KEY = 'YOUR_SERPER_API_KEY'; // Replace with your actual API key
const url = '<https://google.serper.dev/search>';
const payload = {
'q': companyName + ' contact',
'num': 1
};
const options = {
'method': 'post',
'headers': {
'X-API-KEY': API_KEY,
'Content-Type': 'application/json'
},
'payload': JSON.stringify(payload)
};
const response = UrlFetchApp.fetch(url, options);
const result = JSON.parse(response.getContentText());
if (result.organic && result.organic.length > 0) {
return result.organic[0].link;
}
return null;
}