アットウィキロゴ

na77

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tetu;
 
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import tool.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[50000];
 int[] a=new int[100];
 int[] b=new int[100];
 String[] subdata=new String[50000];
 
    public static void main(String[] args) {
       pro test=new pro();
    }
    pro(){
 
        int tr,y1,m1;
 
        y1=2008;
        m1=3;
 
        for(tr=1;tr<106;tr++){
 
        m1=m1+1;
        if(m1>12)y1=y1+1;
         if(m1>12)m1=1;
         String ppp=y1+""+m1;
         if(m1<10)ppp=y1+"0"+m1;
 
String urlx="http://tetsukonohair.jugem.jp/?month="+ppp;
 
 
            getdata sub7=new getdata();
        sub7.makedata(urlx,"EUC-JP");
        data=sub7.data;
        datanumber=sub7.datanumber; 
 
        	String pp="<div class=\"entry\">";
 
                int sx=0;
        for(s=1;s<datanumber+1;s++){
 
       if(data[s].indexOf(pp)>-1)sx=sx+1;
       if(data[s].indexOf(pp)>-1)a[sx]=s; 
        } 
 
        int number=sx;
 
 
 
         for(s=1;s<number+1;s++){
 b[s]=0;
for(sx=a[s]+1;sx<datanumber+1;sx++){
     int h=0;
  if(data[sx].indexOf("http://twitter.com/share")>-1)h=h+1;
 if(b[s]==0)h=h+1; 
 if(h==2)b[s]=sx; 
 }
 } 
 
 
  int tx=0;
 for(s=1;s<number+1;s++){
 for(sx=a[s];sx<b[s];sx++){ 
 data[sx]=change(data[sx]);
 data[sx]=data[sx].replace("  ","");
 data[sx]=data[sx].replace("	","");
 if(data[sx].length()>0)tx=tx+1;
 if(data[sx].length()>0)subdata[tx]=data[sx];
 }
 }     
 
 datanumber=tx;
 
 writexml(ppp+".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.println(subdata[s]); 
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
  String change(String str){
 
        int n;
        for(n=1;n<11;n++){
        str=rev(str);    
        }
 
 
 
        return str;
    }
 
 String rev(String str){
 
        if(str==null)str="";
 
        int p1=str.indexOf("<");
        int p2=-1;
        if(p1>-1)p2=str.indexOf(">",p1);
        String strx="";
        if(p2>-1)strx=str.substring(p1,p2+1);
        str=str.replace(strx,"");
 
        return str;
    }      
 
}
最終更新:2016年12月23日 13:06