0

So my goal is to have a google sheet that collects news from different RSS feeds and updates as new article happen in the feed. So far I have found two "methods", one is inserting "?=atom" at the end of rss feed and using =IMPORTFEED(A1,"items title",TRUE,100) plus other for url and date. The second is just having the RSS url in a cell and =IMPORTFEED(A1,"items",FALSE,100). The first method seems bare bone but perfectly fine, while the second gives the little summary which is nice.

My questions is will one of the two method I use automatically update my google sheets? While maintaining the previous article? If not what do you suggest? I have tried looking at IFTTT and one other. However I found them to be limited due to the way I want to organize the sources and amount of sources I want.

1 Answer 1

0

Open the Google App Script inside your spreadsheet and paste this script:

function rssfeed() {
  var ss = SpreadsheetApp.getActive();
  ss.getRange('Import RSS!A1').setFormula('=IMPORTFEED("https://retail-insider.com/feed/","items Title",False,100)');
  ss.getRange('Import RSS!B1:B').copyTo(ss.getRange('History RSS!A1:A'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  ss.getRange('Import RSS!A1').clear({contentsOnly: true, skipFilteredRows: true}); 
}

Don't forget to change 'YOUR RSS IMPORT FORMULA' to your formula.

Create a spreadsheet page called History RSS.

Create a spreadsheet page called Import RSS and in cell B1 put this formula:

=IFERROR(QUERY(UNIQUE({'History RSS'!A1:A;'Import RSS'!A1:A}),"Where Col1<>''"))

Go back to your Google App Script project and open the Triggers page, on that page you click on add new Trigger and scroll through the options until set so that Trigger is activated every 5 minutes, 10 minutes , 30 minutes, 1 hour or whatever time you prefer.

Okay, that way every time period you've chosen, the script will be activated, put your function in cell A1 of the page Import RSS, the formula of B1 will join the data that already exists in the Column A of the History RSS page and the new data from Column A of the Import RSS page, the script will copy everything to Column A of the History RSS page and finally erase the cell's import formula A1.

That way you can merge old data with new data.

Aditional:

For multiple sites:

function rssfeed() {
  var ss = SpreadsheetApp.getActive();
  //SiteOne
  ss.getRange('Import RSS!A1').setFormula('=IMPORTFEED("https://retail-insider.com/feed/","items Title",False,100)');
  ss.getRange('Import RSS!B1:B').copyTo(ss.getRange('History RSS!A1:A'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  ss.getRange('Import RSS!A1').clear({contentsOnly: true, skipFilteredRows: true}); 
  //SiteTwo
  ss.getRange('Import RSS!A1').setFormula('=IMPORTFEED("https://retail-insider.com/feed/","items Title",False,100)');
  ss.getRange('Import RSS!B1:B').copyTo(ss.getRange('History RSS!A1:A'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  ss.getRange('Import RSS!A1').clear({contentsOnly: true, skipFilteredRows: true});
  //SiteThree
  ss.getRange('Import RSS!A1').setFormula('=IMPORTFEED("https://retail-insider.com/feed/","items Title",False,100)');
  ss.getRange('Import RSS!B1:B').copyTo(ss.getRange('History RSS!A1:A'), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  ss.getRange('Import RSS!A1').clear({contentsOnly: true, skipFilteredRows: true});
}

In the case of multiple sites, edit the formula that will be sent to the spreadsheet (.setFormula()) in each of the imports and change to which column the result will be sent.

And for more sites, just add the part of the code below the //Site... indication

9
  • 1
    Hey, completely my fault, I didn't mention I was super new to this whole "coding" thing. So here is my workflow, So I have a google sheet open. I go to tools, click on script editor. There I paste that line of code you said. Then within that code I change the part is say 'your Rss formula'. What would be my rss formula? is that just the link for the rss feed? For Cell A1 what do you mean by function? Is that just my RSS link as well?
    – John_Muir
    Commented Aug 3, 2021 at 14:34
  • What formula do you use to import the RSS Feed that returns the current data of the page you are looking for? Commented Aug 3, 2021 at 14:43
  • Oh I haven't been using any formula. For example, retail-insider.com/feed Is the Rss feed. I post it in the A1 add the atom thing or leave it normal. Then do the lines of code I noted above.
    – John_Muir
    Commented Aug 3, 2021 at 14:58
  • Would something like =importfeed(retail-insider.com/feed,”items Title”,False,100) work? Then for the function in A1 would that be the same ?
    – John_Muir
    Commented Aug 3, 2021 at 15:08
  • In A1 you won't put anything, who will put it is the script itself automatically. In the spreadsheet you just need to create the pages and put the formula of B1. The rest will all be done automatically. Note, I've already put the correct formula into the script. Commented Aug 3, 2021 at 15:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.