Programmatically Write TechCrunch Headlines to Google Sheets
Tags: wayscript, googlecloud, automation
Published: 2020-06-12 17:33:34

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

![](https://cdn.wayscript.com/blog_img/94/1.png)

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

*   [https://techcrunch.com/pages/rssfeeds/](https://techcrunch.com/pages/rssfeeds/)

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.

*   [Working with Time Trigger](https://docs.wayscript.com/library/triggers/time-trigger)
*   [Working with Python](https://docs.wayscript.com/library/modules/python)
*   [Working with Loops](https://docs.wayscript.com/library/logic/loop)
*   [Working with Google Sheets](https://docs.wayscript.com/library/modules/google-sheets)
*   [Working with RSS Feeds](https://docs.wayscript.com/library/modules/rss-feed)

Getting Started
---------------

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

![](https://cdn.wayscript.com/blog_img/83/1.png)

  
  
Next, we will need to ‘Import’ the _RSS Feed_ and _Google Sheets_ packages from the ‘Libraries > Packages’ menu.  
  

![](https://cdn.wayscript.com/blog_img/104/Libraries.PNG)

  
  
Now, let’s add and enable a simple _Time Trigger_  
  

![](https://cdn.wayscript.com/blog_img/104/time_trigger.PNG)

  
  

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.  
  

![](https://cdn.wayscript.com/blog_img/104/Rss_Feed.PNG)

  
  

Python Parsing
--------------

Our code will simply iterate through the _RSS Feed_ output looking for headlines and store in a new global variable. 
<pre>
variables[ 'headlines' ] = [] 
for key in variables[ 'Rss_Feed' ]
    [ 'entries' ]: variables[ 'headlines' ].append(key[ 'title' ]
</pre>

Headlines Loop
--------------

We add a _Loop_ so that we can output each headline as a new row item for our _Google Sheet_.  
  

![](https://cdn.wayscript.com/blog_img/104/loop.PNG)

  
  

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.  
  

![](https://cdn.wayscript.com/blog_img/104/google_sheets.PNG)

  
  

Result
------

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

![](https://cdn.wayscript.com/blog_img/104/headlines.PNG)

  
  
As always, if you have any questions, comments, feedback, or suggestions, please let us know on WayScript or through our [discord](https://discord.gg/VWbXSbj). If you would like to view this WayScript simply follow the link [TechCrunch Headlines to Google Sheets](https://wayscript.com/user/wizgeeky/L4s6RIWd).