Re: Fetch Google search results for keywords

313 2
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

A simple script to fetch search results from Google based on keywords in your base:

let table = base.getTable('Searches');
let resultsField = table.getField('Results');
let record = await input.recordAsync('Record', table);
let searchQuery = await input.textAsync('Search query');
if (searchQuery) {
    table.updateRecordAsync(record, {[]: 'Updating...'});
    output.markdown(`Searching for ${searchQuery}...`);
    let results = await searchAsync(searchQuery.split(',').map(term => term.trim()).join('\n'));
    await table.updateRecordAsync(record, {[]: results});
async function searchAsync(searchTerm) {
    let response = await fetch(
        `<TASK ID>/run-sync-get-dataset-items?token=<TOKEN>`,
            method: "POST",
            headers: {"content-type": "application/json"},
            body: JSON.stringify({queries: searchTerm}),
    let result = await response.json();
    let resultLines = [];
    for (let {searchQuery, organicResults} of result) {
        resultLines.push(`## ${searchQuery.term}`);
        for (let {title, url, description} of organicResults) {
            resultLines.push(`- [**${title}**:](${url}) ${description}`);
    return resultLines.join('\n');
7 Replies 7

Very cool. Have you thought of a way to cleanly output results into another table or individual records?

Seems like this could be used to check a website’s url against these results, and then tell where your website is ranked among google search results. Could be turned into a customized SERP tracker.

This script uses Apify’s Google Search Results Scraper—they have a lot of useful building blocks for scripts on their site!

5 - Automation Enthusiast
5 - Automation Enthusiast

Hey @Halley_Johnson this is great! (I think). How might I apply this if I wanted to search for a list of fellow artists’ websites if I have name and I want to search for {FullName} + “Artist” or “Art”?

Could this be used to fetch Google Image search results? We’re wanting to pull company logos.

@Brian_Swichkow - for company logos, check out clearbits free logo api:

Thank you @openside!

(1) as a formula field with (2) the MIniExtensions bit Convert URLs to Attachments in Bulk on Airtable, and (3) their Cloudinary bit was EXACTLY the recipe I was looking for.


Thank you for this usefull script !
I need to only fetch the first result of the google search and only the URL not the title or the description.
What are the modifications to do in the script please ?

Thank you !!