我想获得主单元的标题页
我希望得到 СтраховыекомпанииУфы。 АдресаотделенийвУфе
得到 。
示例脚本:
function doGet() {
var options1 = {
contentType: "text/html; charset=windows-1251",
muteHttpExceptions: true
};
var url_catalog = 'http://ufa.insure-company.ru/';
var response = UrlFetchApp.fetch(url_catalog, options1);
var txt = response.getContentText();
doc = Xml.parse(txt, true);
var tbody = doc.html.head;
var title = tbody.getElements("title");
var t = title[0].getText();
return HtmlService.createHtmlOutput(t);
}
答案 0 :(得分:1)
function doGet() {
var options1 = {
contentType: "text/html ",
muteHttpExceptions: true
};
var url_catalog = 'http://ufa.insure-company.ru/';
var response = UrlFetchApp.fetch(url_catalog, options1).getContentText("windows-1251");
doc = Xml.parse(response, true);
var tbody = doc.html.head;
var title = tbody.getElements("title");
var t = title[0].getText();
return HtmlService.createHtmlOutput(t);
}
实际上在旧产品论坛中得到了答案,请参阅答案here
使用getContentText()获取UrlFetchApp类中的上下文。