function myFunction() {
uu="https://ja.wikipedia.org/wiki/%E8%B6%B3%E7%AB%8B%E6%A2%A8%E8%8A%B1";
str="";
try {
var res = UrlFetchApp.fetch(uu);
str=res.getContentText();
} catch (e) { Logger.log("Fail");}
c="<span class=\"mw-headline\" id=\"CM\">";
p1=str.indexOf(c);
c1="<span class=\"mw-headline\" id=\"CM.E3.83.BB.E5.BA.83.E5.91.8A\">";
if(p1<0)p1=str.indexOf(c1);
p2=str.indexOf("mw-headline",p1+25);
str=str.substring(p1,p2);
var x=str.split("\n");
var card=new Array();
var subc=new Array();
sx=0;
subx=0;
for(s=1;s<x.length;s++){
if(x[s].indexOf("<ul>")>-1)subx=100;
if(x[s].indexOf("</ul>")>-1)subx=0;
if(x[s].indexOf("<li>")>-1)sx=sx+1;
if(x[s].indexOf("<li>")>-1)subc[sx]=subx;
if(x[s].indexOf("<li>")>-1)card[sx]=f(x[s]);
}
number=sx;
for(s=1;s<number+1;s++){
Logger.log(subc[s]+","+card[s]);
}
}
function f(str){
strx=str;
for(m=1;m<31;m++){
strx=fresh(strx);
}
strx=strx.replace(" ","");
strx=strx.replace(" ","");
strx=strx.replace(";","");
return strx;
}
function fresh(str){
p1=str.indexOf("<");
p2=str.indexOf(">",p1);
sp="";
if(p1>-1)sp=str.substring(p1,p2+1);
k=str.replace(sp,"");
return k;
}
最終更新:2017年04月23日 19:37