アットウィキロゴ

mesuo

function myFunction() {
 
  uu="http://www.ch-review.net/contents/2305";
 
 
 
   str="";
      try {
 
 var res = UrlFetchApp.fetch(uu);
        str=res.getContentText();
 
    } catch (e) { Logger.log("Fail");}
 
 p1=str.indexOf("<table id=\"star-list\">");
 p2=str.indexOf("</table",p1);
 strx=str.substring(p1,p2);
 
 
 var point=new Array(); 
  var credit=new Array(); 
 
  var x=strx.split("</tr>");
  for(s=0;s<x.length;s++){
 var y=x[s].split("</td>"); 
 point[s]="";
  for(sx=0;sx<y.length;sx++){ 
 if(y[sx].indexOf("件")>-1)point[s]=clean_str(y[sx]);
 }
 Logger.log(point[s]);
  }
 
 
 
 p1=str.indexOf("detail-text-area");
 p2=str.indexOf("</table",p1);
 strx=str.substring(p1,p2);
 
 var x1=strx.split("</tr>");
  for(s=0;s<x1.length;s++){
  var y1=x1[s].split("</td>"); 
 credit[s]="";
  for(sx=0;sx<y1.length;sx++){ 
 if(sx==2)credit[s]=clean_str(y1[sx]);
 }
    for(sx=1;sx<100;sx++){
  credit[s]=credit[s].replace("	","");  
  }
   credit[s]=credit[s].replace("\n","");  
    credit[s]=credit[s].replace("\n","");   
   Logger.log(credit[s]);
 
  }
 
 
 
 
 
}
function clean_str(str){
 
  sp=str;
  for(kk=1;kk<15;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年05月08日 22:37