我现在有一个网页。
<html>
<body>
<div>31423423423
</div>
<div>
<table>
<tr>
<td class = "a">asdfdas</td><th>234</th><td class = "b">12</td>
</tr>
<tr>
<td class = "a">asdfdas</td><th>234</th><td class = "b">123434</td>
</tr>
<tr>
<td class = "a">asdfdas</td><th>234</th><td class = "b">132</td>
</tr>
</table>
</div>
</body>
</html>
import java.util.*;
import java.io.*;
import java.util.regex.*;
public class TableTest {
public static void main(String[] args) {
String rex = "<\\s*td\\s+class\\s+=\\s+\"\\s*b\\s*\"\\s*>(.*)<\\s*/td\\s*>";
//指定要提取的网页
String path = "c:/test.html";
Pattern p = Pattern.compile(rex);
Matcher m = null;
StringBuffer sb = new StringBuffer();
String temp = null;
try {
File f = new File(path);
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
while((temp = reader.readLine()) != null) {
m = p.matcher(temp);
while(m.find()) {
System.out.println(m.group(1));
sb.append(m.group(1) + "!");
}
}
} catch (Exception e) {
}
/////res就是保存的结果
/*
String [] res = sb.toString().split("!");
for(String s: res) {
System.out.println(s);
}
*/
}
}
分享到:
相关推荐
if(macAddressPosition <= 0) continue; String macAddressCandidate = line.substring(macAddressPosition + 1).trim(); if(windowsIsMacAddress(macAddressCandidate)) { lastMacAddress = macAddressCandidate; ...
'+Math.random()">看不清,换一张</a></h2></td> <td align = "center"> <input type="submit" class="button" style=width:70px;height:35px;font-size:13px value="注册"/> </td> </...
<div align="center"><strong><font face="华文楷体"><a href="messagelist.jsp" target="_blank" class="STYLE21">游客留言板</a></font></strong></div></td> </tr> <tr> <td width="56" height="18" bgcolor=...
<td><input type="text" name="username" /></td> </tr> <tr> <td>密码:</td> <td><input type="password" name="password" /></td> </tr> <tr> <td>角 色:</td> ...
body><center><font color=red size=7>92期学员信息如下</font> <hr> <table border=1> <tr> <td>id</td> <td>姓名</td> <td>密码</td> <td>性别</td> <td>年龄</td> <td><center>操 作</center></td> </...
<td ><img src="<%= bk.getPicture()%>" width="80" height="112"></td> </tr> <tr> <td align="right" width="120" valign="top">内容介绍:</td> <td><%= dataFormat.toHtml(bk.getContent()) %></td> </...
//<table border="0" cellspacing="0" cellpadding="5" class="odTable" id="idTable"> // <thead> // <tr> // <td align="center"><span id="idNum">ID</span></td> // <td> <span id="idTitle">名称</span> /...
<td colspan="3" bgColor="#ffffff"><%=(String)session.getAttribute("loginSessionKey")%><font color="#800080" size="6"><strong>你好!当前留言</strong></font><font size="6"> <a href=...
<td colspan="3" bgColor="#ffffff"><%=(String)session.getAttribute("loginSessionKey")%><font color="#800080" size="6"><strong>你好!当前留言</strong></font><font size="6"> <a href=...
<class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>300</height> </rect> </...
out.println("<br><br><br><hr><center><font color=red size=12><B>"); try...{ UserBean user=new UserBean(); if(user.check(name,pword)) out.println("登陆成功"); else out.println("登陆失败"); }...
<td width="318"><input name="username" type="text" id="username"></td> </tr> <tr> <td>密码:</td> <td><input name="password" type="password" id="password"></td> </tr> <tr> <td colspan="2" ...
name="userName" id="userName"></td> </tr> <tr> <td>密码:<input type="password" name="password" id="password"></td> </tr> <tr> <td><input type="submit" value="登录" style="background-color:pink"> ...
"><%=days[i]%> </a> </b> </font> </td> <% } else { %> <td width="27" height="16" align="center"> <a href="#" onClick="window.open('insertInformation.jsp?showtime=<%=showtime%>','','width=500,...
<tr><td colspan="5"><a href="input">添加用户</a></td></tr> <tr> <td> <s:if test="page.hasFirst"><a href="list-users?page.pageNow=<s:property value="1"/>">首页</a></s:if> <s:if test="page.hasPre"><a ...
unity直接从excel中读取数据,暂存数据格式为dic<string,Object>,string为sheet表名,Object为List<表中对应的实体类>,可以自行获取数据进行转换。核心方法为ImportExcelFiles,参数有 string[]<param name=...
<td align="left" valign="middle" nowrap><font color="#FFFFFF"><B>欢迎光临</B></font></td> </tr> </table> </td> </tr> <tr> <td width="3" background="image/link.GIF"></td> <td> <table width=...
<input name="Submit5" type="button" class="btn_grey" value="检测该歌曲是否上传" onClick="opendialog()"></td> </tr> <tr> <td align="center">专 辑 名:</td> <td><input name="specialName" type="text...