0

I have a script to save RSS data into a Spreadsheet, but it still has shortcomings and problems.

I have received data in the form of title, time, article link. https://i.sstatic.net/9YTAF.png

I want the script to be able to retrieve descriptions based on tags or HTML classes from each article link, so that the data I get is title, time, description, article link

For example, I want to retrieve the description of a div class called entry-content from the article link https://e-ficiencia.com/samsung-climate-solutions-acudira-cyr-2023/

My hope is that the data I get on the Spreadsheet will be like this

https://i.sstatic.net/kT00s.png https://docs.google.com/spreadsheets/d/1lPn7xHEEI1NknN8l9w6hu4SkQburm8s-NdAjPsPc-NM/edit#gid=0

Following my Google Apps Script

function myFunction() {
  getURLData();
}

function getURLData() {
 
  var currentData = [];
  var urltoCheck = ["https://e-ficiencia.com/feed/", "https://www.climanoticias.com/feed/all","https://www.proinstalaciones.com/actualidad/noticias?format=feed"];
  for (var i = 0; i < urltoCheck.length; i++){
  var ficiencaData = UrlFetchApp.fetch(urltoCheck[i]);
  var xml = ficiencaData.getContentText()
  let response = XmlService.parse(xml);
  var root = response.getRootElement();
   let channel = root.getChild('channel');
  let items = channel.getChildren('item');
    items.forEach(item => {
      let title = item.getChild('title').getText();
      let pubDateb = item.getChild('pubDate').getText();
      let link = item.getChild('link').getText();
      currentData.push([title,pubDateb,link])
   
  });
}
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName("Sheet1");
  var currentDataRange = sheet.getRange(sheet.getLastRow() + 1, 1, currentData.length, currentData[0].length);
  currentDataRange.setValues(currentData); 
  
}


6
  • Unfortunately, I cannot open your provided Spreadsheet to confirm My hope is that the data I get on the Spreadsheet will be like this. Can you confirm it again? And, I have to apologize for my poor English skill. Unfortunately, from For example, I want to retrieve the description of a div class called entry-content from the article link https://e-ficiencia.com/samsung-climate-solutions-acudira-cyr-2023/, I cannot understand your expected value. Can I ask you about your expected value? Commented Oct 28, 2023 at 12:28
  • @Tanaike i.sstatic.net/kT00s.png Commented Oct 28, 2023 at 12:43
  • Thank you for replying. From your reply, I proposed a modified script as an answer. Please confirm it. If I misunderstood your expected result, I apologize. Commented Oct 28, 2023 at 13:22
  • Thank you for replying. I have to apologize for my poor English skill. From Your answer is not wrong, but it doesn't meet my expectations., I understood that my understanding of your question was not correct. In this case, I have to delete my answer. I deeply apologize for my poor English skill again. When I could correctly understand your question, I would like to think of a solution. Commented Oct 28, 2023 at 14:02
  • Sorry I have troubled and disappointed you, I hope you are not offended by my previous reply Commented Oct 28, 2023 at 15:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.