0
我在站點上運行的腳本出現錯誤:服務錯誤:SitesApp:條目必須具有純文本非空標題(第16行)將從電子表格中提取的信息添加到網站上
function parseNews() {
var SS = SpreadsheetApp.openById("MY_SPREADSHEET_KEY");
var SourcePage = SS.setActiveSheet(SS.getSheetByName("Current"));
var TargetPage = SS.setActiveSheet(SS.getSheetByName("Archive"));
var TotalRows = SourcePage.getLastRow();
var RowCount;
var pages = SitesApp.getSite('mydomain.co.uk','home').getChildren();
Logger.log(pages.length);
for (RowCount=1;RowCount++;RowCount <= TotalRows){
var titleText = SourcePage.getRange(RowCount,2).getValue();
var urlText = SourcePage.getRange(RowCount,3).getValue();
var postType = SourcePage.getRange(RowCount,4).getValue();
var lineEntry = ('<div>'+titleText+'<THEREISANAHREFHERE="'+urlText+'">'+urlText+'</A></div>');
Logger.log(lineEntry);
Logger.log(pages[1].getTitle());
var page = pages[1].setHtmlContent(lineEntry);
Logger.log(page);
}
}
第16行是'var page = pages [1] .setHtmlContent(lineEntry);
記錄輸出:
2.0
<div>The new Samsung Galaxy S III Android Smartphone<A HREF="http://www.bbc.co.uk/news/technology-17935684">http://www.bbc.co.uk/news/technology-17935684</A></div>
和調試時,頁面被 '未定義'
任何想法我做了什麼錯?道歉,如果格式不好,預覽看起來很好! (Ubuntu的12.04 +鍍鉻)
乾杯,
Sladey
嗨,Eric,感謝您的建議。在文件列表中,有一個文件標題爲'[Untitled]'我已經刪除了這個文件,但現在我得到了同樣的錯誤! – Sladey
爲了澄清,我相信您的Google網站上有一個沒有標題的頁面。創建新頁面可能更好,而不是更新現有頁面。 –