DEV Community

Derrick Sherrill for WayScript

Posted on

Programmatically Write TechCrunch Headlines to Google Sheets

Introduction

Have you ever wished you could parse TechCrunch headlines easily and save them to a spreadsheet? With WayScript and Google Sheets you can do exactly that with a few simple steps.

Prerequisites

First, you will need to ‘Share’ your Google Sheet with the following settings and ‘Copy’ the link

Next, you will need to copy the TechCrunch RSS URL for the specific feed you would like to gather headlines for

In this post, we will be using the main ‘TechCrunch’ feed. In order to build the WayScript workflow we will only be needing a Time Trigger, the RSS Feed package, the Google Sheets package, a Python module, and a Loop module.

If you would like to learn more about these modules and packages within WayScript please take a look at the following resources.

Getting Started

Simply, click the ‘+ New Script’ button found in the top right corner to start creating your new workflow.

Next, we will need to ‘Import’ the RSS Feed and Google Sheets packages from the ‘Libraries > Packages’ menu.

Now, let’s add and enable a simple Time Trigger

Add RSS Feed

By using the RSS Feed package we can gather the feed contents and output to a variable for parsing in a single step.

Python Parsing

Our code will simply iterate through the RSS Feed output looking for headlines and store in a new global variable.

variables[ 'headlines' ] = [] 
for key in variables[ 'Rss_Feed' ]
    [ 'entries' ]: variables[ 'headlines' ].append(key[ 'title' ]

Headlines Loop

We add a Loop so that we can output each headline as a new row item for our Google Sheet.

Write to Google Sheets

Finally, we make use of the Google Sheets package to write our headlines to a spreadsheet making sure to ignore duplicate entries.

Result

Let’s take a look at our spreadsheet to verify the WayScript workflow is working as intended:

As always, if you have any questions, comments, feedback, or suggestions, please let us know on WayScript or through our discord. If you would like to view this WayScript simply follow the link TechCrunch Headlines to Google Sheets.

Top comments (0)