这是源代码。
URL url = new URL("http://quote.eastmoney.com/center/list.html#28003629_0_2");
BufferedReader bufin = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
//创建规则
Pattern p = Pattern.compile("[0-9]+\.[0-9]+");
Matcher m = null;
//弄个存的list
List list = new ArrayList();
while((line = bufin.readLine())!=null){
m = p.matcher(line);
while(m.find()){
list.add(m.group());
}
}
for(String s : list){
System.out.println(s);
}
这是结果
1.0
2.0
2.0
4.0
2.5
12.1
12.1
12.1
12.1
12.1
12.2
12.2
14.1
14.1
14.1
14.2
14.2
14.3
14.3
24.1
24.1
24.1
24.2
24.2
24.3
24.3
2.0
2.0
2.0
2.0
2.0
2.0
2.0
1.0
0.25
这是目的网页
http://quote.eastmoney.com/center/list.html#28003629_0_2
原网页里可能上百个数字,,为什么我只爬出来这么几个,,刚才爬贴吧的帖子内的邮箱账户字段 。也爬不出来 室友说 可能有保护政策