function myFunction() {
urlx="https://dot.asahi.com/wa/2017041000066.html";
str="";
try {
var res = UrlFetchApp.fetch(urlx);
str=res.getContentText();
} catch (e) { Logger.log("Fail");}
p1=str.indexOf("<!--本文(クローリング起点)-->");
p2=str.indexOf("トップにもどる</a>",p1);
index=str.substring(p1,p2);
n=1;
for(s=2;s<11;s++){
pp="page="+s;
if(index.indexOf(pp)>0)n=s;
}
var strx="";
for(tr=1;tr<n+1;tr++){
strx=strx+play(urlx,tr);
}
Logger.log(strx);
}
function play(urlx,m){
uu=urlx+"?page="+m;
str="";
try {
var res = UrlFetchApp.fetch(uu);
str=res.getContentText();
} catch (e) { Logger.log("Fail");}
p1=str.indexOf("<!--本文(クローリング起点)-->");
p2=str.indexOf("<!--/本文(クローリング終点)-->",p1);
book=str.substring(p1,p2);
return book;
}
最終更新:2017年04月27日 08:19