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;
}
查看全文
相关阅读:
The connection to the server localhost:8080 was refused
Error: client: etcd cluster is unavailable or misconfigured; error #0: dial tcp 127.0.0.1:4001: getsockopt: connection refused
docker-machine on azure
Spine学习二 -播放Spine动画
第三人称角色控制器解析
3D人物移动控制实现方案
Transform与Vector3 的API
Animator.SetFloat(string name,float value,float dampTime,float deltaTime)详解
Unity坑之 加了Rigidbody后主角反而朝天上飞?
使用代码给Unity中的动画片段绑定回调函数
原文地址:https://www.cnblogs.com/polugen/p/532765.html
最新文章
oracle用dba创建用户并授权
vs工具类SQLhelper参考
vs连接oracle
vs启动报4.X的错
springboot事务
docker好文地址
配置IIS Express以便通过IP地址访问调试的网站
手把手教你如何用 OpenCV + Python 实现人脸识别
25行 Python 代码实现人脸检测——OpenCV 技术教程
Ubuntu无法获得锁 /var/lib/dpkg/lock
热门文章
CentOS Linux解决Device eth0 does not seem to be present
openssh 在32位、64位操作系统上的安装配置
.yml是什么文件
centos7下kubernetes(8.kubernetes Failover)
centos7下kubernetes(7.kubernetesScale Up/Down)
centos7下kubernetes(6。kubernetes创建资源的两种方式)
centos7下kubernetes(6。运行应用)
隔离 docker 容器中的用户-------分享链接
centos7下kubernetes(5。部署kubernetes dashboard)
centos7下kubernetes(4.kubernetes组件)
Copyright © 2011-2022 走看看