Simon Breton Simon Breton - 23 days ago 4x
Javascript Question

"Attribute provided with no value" error on data scraping script

I'm trying to build a little data scraping script with google apps for google sheet. I'm still learning javascript and I'm totally new google script.

I've wrote the code below (with some help, already got an answer from a previous question here) but now I have the following error :

"Attribute provided with no value"
. What happen is that when I'm replacing
with whatever value It's working. So I kind of understand my issue but I don't know how to solve it. I guess that
var urls
isn't a proper array...

Here is my code :

function getArray() {
var newData = new Array();
var sheet = SpreadsheetApp.openById('my_id').getSheetByName('Sheet2');
var urls = sheet.getRange("A1:A").getValues();
var fromText = '<span class="nb-shares">';
var toText = '</span>';

for(var i = 0; i < urls.length; i++){
var url = urls[i];
var content = UrlFetchApp.fetch(url).getContentText();
var scraped = Parser


var sheet2 = SpreadsheetApp.openById('my_id').getSheetByName('Sheet5');
sheet2.getRange(1, 1, newData.length, newData[1].length).setValues(newData);

Forgot to mention : I'm using
Parser library


The getValues() method returns a 2 dimensional array. You are not getting the value out of the inner array.


var url = urls[i];

Should be:

var url = urls[i][0];

You need to add the [0] index for the inner array.