#10882

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://mainichi.jp/select/opinion/editorial/”, false);
http.send(“”);

//社説のアドレスを検索
var nFlags = eeFindNext|eeFindReplaceQuiet;
document.selection.StartOfDocument();
if (document.selection.Find(“

“,nFlags)) {
document.selection.CharLeft();
//最初に見つかったリンクを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);
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”, “http://mainichi.jp/select/opinion/editorial/news/” + document.selection.Text, false);
ss.send(“”);
//先頭削除
Trim_Data(“”,”

“);
//関連記事削除
Trim_Data(“

“,”

“);
//末尾削除
Trim_Data(““,””);
//タグ削除
DeleteTags(1,1);
}
}
}

//余録をGET
document.selection.EndOfDocument();
document.selection.NewLine();
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”, “http://mainichi.jp/select/opinion/yoroku/”, false);
col.send(“”);

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

“);
//関連記事削除
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);
}