アットウィキロゴ

dlx

package dl;
 
import tool.*;
import java.io.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[5000];
 String[] article=new String[5000];
 String[] link=new String[50000];
 String[] title=new String[50000];
 String[] good=new String[50000];
 String[] com=new String[50000];
 String[] time=new String[50000];
 
    public static void main(String[] args) {
        pro t=new pro();
    }
 
    pro(){
 
        int n=0;
        for(int tr=1;tr<1422;tr++){
 
        String urlx="http://ameblo.jp/ske48official/entrylist-"+tr+".html";
 
        System.out.println(tr);
 
   getdata sub=new getdata();
   sub.makedata(urlx,"UTF-8");
   data=sub.data;
   datanumber=sub.datanumber;
 
   int s1=0;
   for(s=1;s<datanumber+1;s++){
   if(data[s].indexOf("\"blogContent")>-1)s1=s;    
   }
 
   int s2=0;
   for(s=s1;s<datanumber+1;s++){
   if(data[s].indexOf("</article>")>-1)s2=s;        
   }
 
   String str="";
    for(s=s1;s<s2;s++){
    str=str+data[s];  
 
   }
 
    String[] x=str.split("</li>");
    int sx=0;
    for(s=0;s<x.length;s++){
     sx=sx+1;
    article[sx]=x[s];
 
    }
 
 
    int number=sx-1;
     for(s=1;s<number+1;s++){
     n=n+1;
 
     int p1=article[s].indexOf("contentTitle");
     p1=article[s].indexOf("http",p1);
     int p2=article[s].indexOf("html",p1);
     link[n]="";
     if(p1>-1)link[n]=article[s].substring(p1,p2)+"html";
     p1=article[s].indexOf(">",p2);
     p2=article[s].indexOf("<",p1);
     title[n]="";
     if(p1>-1)title[n]=article[s].substring(p1+1,p2);
     p1=article[s].indexOf("コメント",p2);
     p2=article[s].indexOf("<",p1);
     com[n]="";
     if(p1>-1)com[n]=article[s].substring(p1,p2);
     p1=article[s].indexOf("いいね!",p2);
     p2=article[s].indexOf("<",p1);
     good[n]="";
     if(p1>-1)good[n]=article[s].substring(p1,p2);
      p1=article[s].indexOf("<time>");
     p2=article[s].indexOf("</time>",p1);
    time[n]="";
     if(p1>-1)time[n]=article[s].substring(p1,p2);
    time[n]=time[n].replace("<time>",""); 
     } 
 
        }
 
 
        datanumber=n;
 
        writexml("ske.txt");
 
 
 
 
 
    }
 
 
    void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<datanumber+1;s++){   
pw.print("<time>"); 
pw.print(time[s]); 
pw.print("</time>"); 
pw.print("<title>"); 
pw.print(title[s]); 
pw.print("</title>"); 
pw.print("<link>");
pw.print(link[s]);
pw.print("</link>"); 
pw.print("<com>");
pw.print(com[s]);
pw.print("</com>"); 
pw.print("<good>");
pw.print(good[s]); 
pw.println("</good>");
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
}
 
最終更新:2016年04月17日 18:39