Search code examples
google-apps-scriptgoogle-sheetsgoogle-sites

Google Site Script to dynamically add posts from Google Sheet


I have a Python cron job that pulls urls from sheet1 and populates sheet2 with scraped data from each url. Sheet 2 consists of [url, title, body, image urls]

I have an Old Google Site where I manually take sheet2's contents and create a new post. I want to automate this.

Structurally speaking would Google Scripts be able to pull and publish this dynamically? Lets say every time Sheet2 is updated (or a set interval).

I've worked with gscripts but never touched Google Sites before today.


Solution

  • The answer is probably yes. Apps script can do this. You have a couple of options.

    Old Google sites

    Option 1

    Embed an apps script into the site as an iframe and stream you posts in that.

    Option 2

    Use either a standalone apps script or one attached to the google site and update the site using the Google Sites API.

    New Google sites

    Currently there is no apps script API for the new google sites. But you can embed JS HTML etc as a frame in the new sites. You can even use CDN libraries. Which means you can pull data from your sheet using something like AJAX.

    Custom built option

    The Google Sites API can be accessed anywhere you can handle Oauth. This means you can update Google Site from server-side code or from any client if you can handle Oauth.