function myFunction() {
urlx="https://blogs.yahoo.co.jp/ayayakashiwagijp/45385162.html";
str="";
try {
var res = UrlFetchApp.fetch(urlx);
str=res.getContentText("EUcJP");
} catch (e) { Logger.log("Fail");}
var x=str.split("\n");
s1=0;
for(s=1;s<x.length;s++){
if(x[s].indexOf("articleBody")>-1)s1=s;
}
s2=0;
for(s=s1;s<x.length;s++){
h=0;
if(s2==0)h=h+1;
if(x[s].indexOf("</table>")>-1)h=h+1;
if(h==2)s2=s;
}
doc = DocumentApp.create("Title");
for(s=s1+1;s<s2;s++){
x[s]=clean_str(x[s]);
doc.appendParagraph(x[s]);
}
doc.saveAndClose();
}
function clean_str(str){
sp=str;
for(kk=1;kk<250;kk++){
sp=fresh(sp);
}
return sp;
}
function fresh(strstr){
strstr=""+strstr;
p1=strstr.indexOf("<")
p2=-1;
if(p1>-1)p2=strstr.indexOf(">",p1)
k="";
if(p2>-1)k=strstr.substring(p1,p2)+">";
strxp=strstr.replace(k,"");
return strxp;
}
最終更新:2017年08月21日 20:36