0
votes

and thanks for reading! I'm trying to move data from a webpage in .aspx format to my Google Spreadsheet. Altough the target page is dynamic, it has the option to generate static links, like https://www.fasteconomicnews.com/fx_calendar.aspx?s=AF74EM4Y

Anyways, I was trying the very useful and basic script shared by Mark Cameron, but apparently my reply goes above the max number of characters per cell allowed. I would appreciate any tip in fixing this!

This is the code I'm currently using:

function showMessageBox() {
  Browser.msgBox('You touched me!');
  getWebsite();
}

function getWebsite() {

  var attValue = '';

  // making a call to the target website
  var response = UrlFetchApp.fetch("https://www.fasteconomicnews.com/fx_calendar.aspx?s=AF74EM4Y");

  //logging response from target website - In Script Editor > View > Logs
  Logger.log(response.getContentText());

  //parsing the response data from website
  //https://developers.google.com/apps-script/reference/url-fetch/http-response
  var rawData = response.getContentText();

  //setting the spreadsheet and cell location to place the website data
  //make sure to open a new sheet 
  //Link: https://developers.google.com/apps-script/reference/spreadsheet/sheet#getrangerow-column
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[1]);
  var cell = sheet.getRange(1, 1);
  cell.setValue(rawData);
}

Thanks a lot!

1

1 Answers

0
votes

As the error:

Your input contains more than the maximum of 50000 characters in a single cell.

makes clear, you can not fetch urls with more than 50000 characters.

Your url currently contains more than 71000 characters.

Workaround:

  1. Create backend app using google sheets services, f.e. Node.js Quickstart
  2. Make a use of standard javascript Fetch API to download data from desired url
  3. Use spreadsheets.values.update to update your spreadsheet
  4. Do your staff with Apps Script

Reference: