zoukankan
html css js c++ java
正则表达式分析网页,获得中央一电视节目列表
String strUrl
=
"
http://www.cctv.com/tvguide/11/01/20061010/1.shtml
"
;
byte
[] pageHtml
=
HttpUtil.getPage(strUrl);
//
将页面转成string
String strHtml
=
new
String(pageHtml,
"
GB2312
"
);
String[][] ls
=
null
;
ls
=
StringUtil.splitByReg(strHtml,
"
(\\d{2}:\\d{2}:\\d{2})</font>.*<font >(.+)</font>.*</tr>\\r\\n<tr>
"
);
for
(
int
i
=
0
;i
<
ls.length;i
++
)
{
//
String[] ls1[] = StringUtil.splitByReg(ls[i],"");
System.out.print(ls[i][
0
]
+
"
##
"
+
ls[i][
1
]);
System.out.println();
}
/** */
/**
通用正则表达式解析函数
* splitByReg
*
@param
str 需要解析的字符串
*
@param
regExp 匹配的正则表达式
*
@return
解析后字符串数组
*/
public
static
String[][] splitByReg(String str,String regExp)
{
Pattern sp
=
Pattern.compile(regExp);
Matcher matcher
=
sp.matcher(str);
Vector
<
Vector
<
String
>>
colInoput
=
new
Vector
<
Vector
<
String
>>
();
while
(matcher.find())
{
Vector
<
String
>
v
=
new
Vector
<
String
>
();
for
(
int
i
=
1
;i
<=
matcher.groupCount();i
++
)
{
v.add(matcher.group(i));
}
colInoput.add(v);
}
String[][] resultList
=
null
;
if
(colInoput.size()
>
0
)
resultList
=
new
String[colInoput.size()][colInoput.get(
0
).size()];
for
(
int
i
=
0
;i
<
colInoput.size();i
++
)
{
String[] kk
=
new
String[colInoput.get(i).size()];
colInoput.get(i).copyInto(kk);
resultList[i]
=
kk;
}
return
resultList;
}
查看全文
相关阅读:
WEB上传大文件解决方案
上传大文件的解决方案
网页文件断点上传
超大文件上传方案(B/S)
asp.net选择文件夹上传
java文件断点上传
超大文件上传方案(网页)
web选择文件夹上传
jsp选择文件夹上传
jsp文件断点上传
原文地址:https://www.cnblogs.com/polugen/p/532765.html
最新文章
Spring MVC Content Negotiation 转载
Spring配置中的"classpath:"与"classpath*:"的区别研究(转)
报表嵌入到.net系统页面
未找到导入的项目,请确认 <Import> 声明中的路径正确
数据权限功能使用说明
Web应用程序使用说明
制作系统升级安装包工具使用说明
业务操作行为导图
平台导出操作在目标库中对应的数据表
源码目录说明
热门文章
淘宝微信互相屏蔽影响了谁
微信公众平台2013.08.05更新说明
微信5.0安卓内测版下载
微信公众平台高级功能
微信公众平台开发(52)大转盘
Android菜鸟的成长笔记(3)——给QQ登录界面说So Easy
Android菜鸟的成长笔记(23)——获取网络和SIM卡信息
Android菜鸟的成长笔记(22)——Android进程间传递复杂数据(AIDL)
Android菜鸟的成长笔记(2)——第一个Android应用
Linux管理日记(一)
Copyright © 2011-2022 走看看