package toyo;
import tool.*;
import epub.epub;
public class pro {
int s,datanumber;
String[] data=new String[5000];
String[] subdata=new String[5000];
String[] paper=new String[5000];
String[] link=new String[5000];
public static void main(String[] args) {
pro t=new pro();
}
pro(){
for(s=144600;s<144619;s++){
String urlx="http://toyokeizai.net/articles/-/"+s;
art sub=new art();
sub.makedata(urlx);
}
}
}
package toyo;
import tool.*;
import epub.epub;
public class art {
int s,datanumber;
String[] data=new String[5000];
String[] subdata=new String[5000];
String[] paper=new String[5000];
String[] link=new String[5000];
public static void main(String[] args) {
pro t=new pro();
}
void makedata(String urlx){
link[1]=urlx;
getdata sub=new getdata();
sub.makedata(urlx,"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
String str1="<span class=\"page\">";
int sx=1;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str1)>-1)sx=sx+1;
if(data[s].indexOf(str1)>-1)link[sx]=data[s];
}
int number=sx;
String title="";
String author="東洋経済";
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("<title>")>-1)title=data[s];
}
title=change(title);
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf("author_name")>-1)author=data[s];
}
author=change(author);
System.out.println(title);
System.out.println(author);
for(s=2;s<number+1;s++){
int p1=link[s].indexOf("/articles/");
int p2=link[s].indexOf("\"",p1+1);
link[s]="http://toyokeizai.net"+link[s].substring(p1,p2);
}
int tr;
int tx=0;
String[] subtitle=new String[20];
int[] subnumber=new int[50];
String[][] subx=new String[20][5000];
for(tr=1;tr<number+1;tr++){
getdata sub2=new getdata();
sub2.makedata(link[tr],"UTF-8");
data=sub2.data;
datanumber=sub2.datanumber;
String a1="article-body-inner\"";
int s1=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(a1)>-1)s1=s;
}
String a2="article-body-inner";
int s2=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(a2)>-1)s2=s;
}
tx=0;
for(s=s1+1;s<s2;s++){
tx=tx+1;
subdata[tx]=data[s];
}
int delta=tx;
for(s=1;s<delta+1;s++){
subdata[s]=change(subdata[s]);
}
sx=0;
for(s=1;s<delta+1;s++){
if(subdata[s].length()>0)sx=sx+1;
if(subdata[s].length()>0)paper[sx]=subdata[s];
}
delta=sx;
int n1=title.indexOf("|");
if(n1>0)title=title.substring(0,n1);
subnumber[tr]=delta;
subtitle[tr]="p"+tr;
for(s=1;s<delta+1;s++){
subx[tr][s]=paper[s];
}
}
epub sub2=new epub();
sub2.number=number;
sub2.subtitle=subtitle;
sub2.paper=subx;
sub2.subnumber=subnumber;
sub2.title=title;
sub2.author=author;
sub2.makedata("data/"+title+".kepub.epub");
}
String change(String str){
int n;
for(n=1;n<11;n++){
str=rev(str);
}
str=str.replace(" ","");
return str;
}
String rev(String str){
if(str==null)str="";
int p1=str.indexOf("<");
int p2=str.indexOf(">",p1);
String strx="";
if(p2>-1)strx=str.substring(p1,p2+1);
str=str.replace(strx,"");
return str;
}
}
最終更新:2016年11月11日 10:52