#10897

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,”euc-jp”);
}
}
http.open(“GET”, “http://www.asahi.com/paper/editorial.html”, false);
http.send(“”);
//先頭から社説1の前まで削除
Trim_Data(“”,”

“);
document.write(“#社説1n”);
//社説1の終わりから社説2の前まで削除
Trim_Data(“

検索フォーム

“,”

“);
document.write(“#社説2n”);
//社説2の終わりから最後まで削除
Trim_Data(“

検索フォーム

“,””);
//タグ削除
DeleteTags(1,1);

//天声人語をGET
document.selection.EndOfDocument();
document.write(“n#天声人語n”);
var xPos = document.selection.GetActivePointX(eePosLogicalA);
var yPos = document.selection.GetActivePointY(eePosLogical);
OutputBar.writeln(“天声人語取得中…”);
var tj = new ActiveXObject(“Msxml2.XMLHTTP.6.0″);
tj.onreadystatechange = function() {
if (tj.readyState == 4 && tj.status == 200) {
BinaryToText(tj.responseBody,”euc-jp”);
}
}
tj.open(“GET”, “http://www.asahi.com/paper/column.html”, false);
tj.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);
}