#10865
okita
参加者

読売新聞の社説と編集手帳をGETします。

なんでかしらないけどCODEタグの中に書いた「>」が「>」に変換されてしまいます。

//読売新聞の社説と編集手帳を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) {
To_sjis(http.responseBody);
}
}
http.open(“GET”, “http://www.yomiuri.co.jp/editorial/”, false);
http.send(null);
document.selection.StartOfDocument();
//検索オプション
nFlags = eeFindNext|eeFindReplaceQuiet;
//社説を探す
if (document.selection.Find(“

社説

“, nFlags)) {
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);
//社説へのリンクを保存
var strSyasetu = “
http://www.yomiuri.co.jp/editorial/news/” + document.selection.Text;
//編集手帳を探す
document.selection.StartOfDocument();
document.selection.Find(“/editorial/column1/”, nFlags);
document.selection.StartOfLine();
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);
var strSyunju = “
http://www.yomiuri.co.jp” + document.selection.Text;
var xSyunju;
var ySyunju;
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();
To_sjis(ss.responseBody);
Trim_Data(1,1);
document.selection.EndOfDocument();
document.selection.NewLine();
xSyunju = document.selection.GetActivePointX(eePosLogicalA);
ySyunju = document.selection.GetActivePointY(eePosLogical);
}
}
ss.open(“GET”, strSyasetu, false);
ss.send(null);
}
}
//編集手帳をGET
OutputBar.writeln(“編集手帳取得中…”);
ht = new ActiveXObject(“Msxml2.XMLHTTP.6.0”);
ht.onreadystatechange = function() {
if (ht.readyState == 4 && ht.status == 200) {
To_sjis(ht.responseBody);
Trim_Data(xSyunju,ySyunju);
}
}
ht.open(“GET”, strSyunju, false);
ht.send(null);
}
OutputBar.Visible = false;
document.selection.StartOfDocument();
Redraw=true;

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

//トリミング
function Trim_Data(xStart,yStart) {
//本文から前を削除
var nFlags = eeFindNext|eeFindReplaceQuiet;
document.selection.StartOfDocument();
document.selection.SetActivePoint(eePosLogicalA,xStart,yStart);
document.selection.Find(““,nFlags);
document.selection.CharRight();
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();
//本文から後ろを削除
document.selection.Find(““,nFlags);
document.selection.CharLeft();
var xPos = document.selection.GetActivePointX(eePosLogicalA);
var yPos = document.selection.GetActivePointY(eePosLogical);
document.selection.SetActivePoint(eePosLogicalA,xPos,yPos);
document.selection.SetAnchorPoint(eePosLogicalA,xPos,yPos);
document.selection.EndOfDocument(true);
document.selection.Delete();
//タグや空白を削除
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);
}