アットウィキロゴ

buuiio+

var mag=new Array();
var comx=new Array();
var sale=new Array();
 
function myFunction() {
 
  sx=0;
  for(tr=1;tr<57;tr++){ 
 
    uu="http://www.j-magazine.or.jp/magadata/index.php?module=list&action=list&cat1cd=1&cat3cd="+tr+"&period_cd=34";
 
  str="";
      try {
 
 var response = UrlFetchApp.fetch(uu);
 str=response.getContentText("euc-jp");
 
    } 
    catch (e) {}
 
 
 
 
 p1=str.indexOf("list_hierar_text");
 p1=str.indexOf("<table>",p1);
  p2=str.indexOf("</table>",p1);
 
 str=str.substring(p1,p2); 
 
  var x=str.split("</tr>");
 
 
  for(s=1;s<x.length-1;s++){
  sx=sx+1;
  var x1=x[s].split("</td>");  
  mag[sx]=play(x1[0]);
  comx[sx]=play(x1[1]);
  sale[sx]=play(x1[2]);
  }
 
  }  
 
  number=sx;
 
var id="1Xedf83bbFCFSaUeFTbQX-XKSPcjTO-k15mXgMT5g1PQ";
 
var ex = SpreadsheetApp.openById(id);
var sh = ex.getSheetByName("data"); 
 
var v=new Array();
  for(s=0;s<number+1;s++){
  v[s]=new Array();
  }
  v[0][2]="sale";
 
 
  for(s=1;s<number+1;s++){
  v[s][0]=mag[s];
  v[s][1]=comx[s];
  v[s][2]=sale[s];
  }
 
  sh.getRange(1,1,number+1,3).setValues(v);
 
 
}
 
function play(str){
 
 
 
  sp=str;
  for(kk=1;kk<10;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年04月16日 21:05