/*
* import java.io.BufferedReader;
* import java.io.File;
* import java.io.FileReader;
* import java.io.IOException;
* import java.util.regex.Matcher;
* import java.util.regex.Pattern;
*/
import java.io.*;
import java.util.regex.*;
public class GuPiaoShuJu {
public static void main(String[] args) throws IOException{
String s;
int i = 0;
//网页文件位置
String emailHtml = "D:\\白云机场.html";
FileReader fr = new FileReader(new File(emailHtml));
BufferedReader br = new BufferedReader(fr);
FileOutputStream fos = new FileOutputStream("D:\\XiAoOMAn\\GuPiao.txt");
OutputStreamWriter ows = new OutputStreamWriter(fos);
Pattern q = Pattern.compile("((?<=g>)(\\w*?)).*?(?=(</strong>))");
Pattern p = Pattern.compile("((?<=date=)(\\w*?)).*?(?=('>))|((?<=center\">)(\\d{1,7}?)).*?(?=(</div>))");
String str = null;
while ((str = br.readLine()) != null) {
Matcher n = q.matcher(str);
Matcher m = p.matcher(str);
while(n.find()){
s = String.valueOf(n.group());
ows.write(s + " ");
System.out.printf("%-44s",n.group());
}
while(m.find()){
if(i == 0)
System.out.println();
i++;
s = String.valueOf(m.group());
ows.write(s + " ");
System.out.printf("%-22s",m.group());
if(i%7 == 0)
System.out.println();
}
}
ows.close();
fos.close();
br.close();
br.close();
}
}
本地 白云机场 数据抓取
最新推荐文章于 2022-11-03 20:23:22 发布