0

ヘッドユニットのタイトルページを取得したかった

私はСтраховыекомпанииУфыを取得することを期待しています。АдресаотделенийвУфе

そして、����������������������を取得します。����������������������</p>

サンプルスクリプト:

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);
}
4

1 に答える 1

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);
}

それは実際に古い製品フォーラムで回答されました ここで回答を参照してください

getContentText() を使用して、UrlFetchApp クラスでコンテキストを取得します。

実施例

于 2013-01-07T02:28:41.643 に答える