#10910
okita
参加者

//産経ニュースの主張と産経抄をGET
editor.newFile();
OutputBar.clear();
OutputBar.Visible = true;
OutputBar.writeln(“産経ニュース取得中…”);
Redraw = false;
var http = new ActiveXObject(“Msxml2.XMLHTTP.6.0″);
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
BinaryToText(http.responseBody,”utf-8”);
}
}
http.open(“GET”, “http://sankei.jp.msn.com/column/topicslist/column-t.htm”, false);
http.send(“”);

//社説のアドレスを検索
var nFlags = eeFindNext|eeFindReplaceQuiet;
var strURL = “http://sankei.jp.msn.com/column/topicslist/”;
var strADR1 = “”;
var strADR2 = “”;
document.selection.StartOfDocument();
if (document.selection.Find(“

主張

..*”>もっと読む”,nFlags | eeFindReplaceRegExp)) {
document.selection.CharRight();
//最初に見つかったリンクをGET
if (document.selection.Find(“【主張】”,nFlags)) {
document.selection.CharLeft();
xEnd = document.selection.GetActivePointX(eePosLogicalA);
yEnd = document.selection.GetActivePointY(eePosLogical);
document.selection.SetActivePoint(eePosLogicalA,xPos,yPos);
document.selection.SetAnchorPoint(eePosLogicalA,xPos,yPos);
document.selection.SetActivePoint(eePosLogicalA,xEnd,yEnd,true);
strADR1 = strURL + document.selection.Text;
//産経抄のアドレス検索
document.selection.StartOfDocument();
if (document.selection.Find(“

産経抄

..*”>もっと読む“,nFlags | eeFindReplaceRegExp)) {
document.selection.CharRight();
//最初に見つかったリンクをGET
if (document.selection.Find(“【産経抄】”,nFlags)) {
document.selection.CharLeft();
xEnd = document.selection.GetActivePointX(eePosLogicalA);
yEnd = document.selection.GetActivePointY(eePosLogical);
document.selection.SetActivePoint(eePosLogicalA,xPos,yPos);
document.selection.SetAnchorPoint(eePosLogicalA,xPos,yPos);
document.selection.SetActivePoint(eePosLogicalA,xEnd,yEnd,true);
strADR2 = strURL + document.selection.Text;
}
}
}
OutputBar.writeln(“社説データ取得中…”);
ss = new ActiveXObject(“Msxml2.XMLHTTP.6.0″);
ss.onreadystatechange = function() {
if (ss.readyState == 4 && ss.status == 200) {
document.selection.SelectAll();
document.selection.Delete();
BinaryToText(ss.responseBody,”utf-8”);
}
}
ss.open(“GET”, strADR1, false);
ss.send(“”);
document.selection.StartOfDocument();
//先頭削除
Trim_Data(“”,”

“);
//「次のページ」表示が見つかった場合
if (document.selection.Find(“

“,nFlags)) {
document.selection.CharRight();
if (document.selection.Find(“
2″,nFlags)) {
document.selection.CharLeft();
xEnd = document.selection.GetActivePointX(eePosLogicalA);
yEnd = document.selection.GetActivePointY(eePosLogical);
document.selection.SetActivePoint(eePosLogicalA,xPos,yPos);
document.selection.SetAnchorPoint(eePosLogicalA,xPos,yPos);
document.selection.SetActivePoint(eePosLogicalA,xEnd,yEnd,true);
}
}
strADR1 = strURL + document.selection.Text;
OutputBar.writeln(“社説データ2ページ目取得中…”);
ss2 = new ActiveXObject(“Msxml2.XMLHTTP.6.0″);
ss2.onreadystatechange = function() {
if (ss2.readyState == 4 && ss2.status == 200) {
document.selection.SelectAll();
document.selection.Delete();
BinaryToText(ss2.responseBody,”utf-8”);
}
}
http.open(“GET”, strADR1, false);
http.send(“”);
document.selection.StartOfDocument();
//1ページ目末尾から2ページ目先頭まで削除
Trim_Data(“

“,”

“);
//「次のページ」表示削除
Trim_Data(“

“,”

  • 次のページ >
  • “);
    }
    //末尾削除
    Trim_Data(““,””);
    //タグ削除
    DeleteTags(1,1);
    document.selection.StartOfDocument();
    document.write(“産経ニュース【主張】n”);
    }
    }
    }

    //産経抄をGET
    document.selection.EndOfDocument();
    document.write(“n【産経抄】n”);
    var xPos = document.selection.GetActivePointX(eePosLogicalA);
    var yPos = document.selection.GetActivePointY(eePosLogical);
    OutputBar.writeln(“産経抄取得中…”);
    var col = new ActiveXObject(“Msxml2.XMLHTTP.6.0″);
    col.onreadystatechange = function() {
    if (col.readyState == 4 && col.status == 200) {
    BinaryToText(col.responseBody,”utf-8”);
    }
    }
    col.open(“GET”, strADR2, false);
    col.send(“”);

    //HTMLの先頭から本文の前まで削除
    Trim_Data(“”,”

    “);
    //本文の終わりから最後まで削除
    Trim_Data(““,””);
    //タグ削除
    DeleteTags(xPos,yPos);

    OutputBar.Visible = false;
    document.selection.StartOfDocument();
    Redraw=true;

    //コード変換
    function BinaryToText(responseBody,strCharset) {
    var st = new ActiveXObject(“ADODB.Stream”);
    st.Type = 1; //バイナリ指定
    st.Open();
    st.Write(responseBody);
    st.Position = 0; //ポジション
    st.Type = 2; //テキスト
    st.charset = strCharset;
    document.write(st.ReadText(-1));
    st.Close();
    }

    //トリミング
    function Trim_Data(strStart,strEnd) {
    var nFlags = eeFindNext|eeFindReplaceQuiet;
    //削除開始位置を設定
    document.selection.StartOfDocument();
    if (strStart.length > 0) {
    if (document.selection.Find(strStart,nFlags)) {
    document.selection.CharLeft();
    } else {
    return;
    }
    }
    var xStart = document.selection.GetActivePointX(eePosLogicalA);
    var yStart = document.selection.GetActivePointY(eePosLogical);
    //削除終了位置を設定
    if (strEnd.length == 0) {
    document.selection.EndOfDocument();
    } else {
    if (document.selection.Find(strEnd,nFlags)) {
    document.selection.Collapse();
    document.selection.CharLeft();
    } else {
    return;
    }
    }
    var xEnd = document.selection.GetActivePointX(eePosLogicalA);
    var yEnd = document.selection.GetActivePointY(eePosLogical);
    //削除
    document.selection.SetActivePoint(eePosLogicalA,xStart,yStart);
    document.selection.SetAnchorPoint(eePosLogicalA,xStart,yStart);
    document.selection.SetActivePoint(eePosLogicalA,xEnd,yEnd,true);
    document.selection.CharRight(true);
    document.selection.Delete();
    }

    //タグや空白を削除
    function DeleteTags(xStart,yStart) {
    document.selection.SetActivePoint(eePosLogicalA,xStart,yStart);
    document.selection.SetAnchorPoint(eePosLogicalA,xStart,yStart);
    document.selection.EndOfDocument(true);
    document.selection.CharRight(true);
    document.selection.Replace(“<”,””,eeReplaceAll|eeReplaceSelOnly);
    document.selection.Replace(” “,””,eeReplaceAll|eeReplaceSelOnly);
    document.selection.Replace(“|]*>”,””,eeFindReplaceRegExp|eeReplaceAll|eeReplaceSelOnly);
    document.selection.Replace(“t”,””,eeFindReplaceEscSeq|eeReplaceAll|eeReplaceSelOnly);
    document.selection.Replace(“^ ..*$”,””,eeFindReplaceRegExp|eeReplaceAll|eeReplaceSelOnly);
    document.selection.Replace(“^n”,””,eeFindReplaceRegExp|eeReplaceAll|eeReplaceSelOnly);
    }