本文整理汇总了Java中org.htmlparser.tags.TableTag类的典型用法代码示例。如果您正苦于以下问题:Java TableTag类的具体用法?Java TableTag怎么用?Java TableTag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableTag类属于org.htmlparser.tags包,在下文中一共展示了TableTag类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertion
import org.htmlparser.tags.TableTag; //导入依赖的package包/类
private Assertion assertion() throws SyntaxError {
NodeList headerColumns = new NodeList();
headerColumns.add( new TableColumn() );
TableHeader tableHeader = new TableHeader();
tableHeader.setChildren( headerColumns );
NodeList rowColumns = new NodeList();
rowColumns.add( new TableColumn() );
TableRow tableRow = new TableRow();
tableRow.setChildren( rowColumns );
NodeList rows = new NodeList();
rows.add( tableHeader );
rows.add( tableRow );
TableTag tableTag = new TableTag();
tableTag.setChildren( rows );
TestPage testPage = new WikiTestPage( new WikiPageDummy());
SlimTestContext testContext = new SlimTestContextImpl( testPage );
Table table = new HtmlTable( tableTag );
List<SlimAssertion> list = new QueryTable( table, "id", testContext ).getAssertions();
return list.get( 0 );
}
示例2: preencheMapaFeriadosEstaduais
import org.htmlparser.tags.TableTag; //导入依赖的package包/类
private void preencheMapaFeriadosEstaduais() throws IOException, ParserException,ParseException {
String estadosPage = recuperarDadosEstado();
StringBuilder stringBuilder = new StringBuilder(estadosPage);
stringBuilder.delete(0,estadosPage.indexOf("<h3"));
NodeList nodeEstadoList = filterTable(stringBuilder.toString());
String todosMeses[] = {"janeiro", "fevereiro", "março", "abril", "maio", "junho", "julho", "agosto", "setembro", "outubro", "novembro", "dezembro"};
Map<String,String> mapaMeses = new HashMap<String,String>();
int i = 1;
for (String mes:todosMeses){
String valor = String.valueOf(i++);
if(valor.length()< 2){
valor ="0"+valor;
}
mapaMeses.put(mes,valor);
}
String estado = null;
for (Node node:nodeEstadoList.toNodeArray()){
if(node instanceof TableTag){
NodeList lista = ((TableTag) node).searchFor(TableColumn.class, true);
SimpleNodeIterator iterator = lista.elements();
while (iterator.hasMoreNodes()){
Feriado feriado = new Feriado();
Node data = iterator.nextNode();
String[] dataExtenso = data.toPlainTextString().split(" de ");
feriado.setData(dataExtenso[0] + "/" + mapaMeses.get(dataExtenso[1]) + "/2015");
Node nome = iterator.nextNode();
feriado.setNome(nome.toPlainTextString());
Node lei = iterator.nextNode();
if(dataExtenso[0].length()==1){
dataExtenso[0] = "0"+dataExtenso[0];
}
System.out.println(dataExtenso[0] + "/" + mapaMeses.get(dataExtenso[1]) + "/2015,"+nome.toPlainTextString()+","+mapaEstados.get(estado));
mapaFeriadosEstado.get(estado).add(feriado);
}
}
if(node instanceof HeadingTag){
estado = node.getChildren().toHtml().trim();
if(node.getChildren().elementAt(0).getChildren() != null){
estado = node.getChildren().elementAt(0).getChildren().toHtml().trim();
}
mapaFeriadosEstado.put(estado,new ArrayList<Feriado>());
}
}
}
示例3: visit
import org.htmlparser.tags.TableTag; //导入依赖的package包/类
/**
* 更新最新的部门发文
* @param httpConn
* @throws Exception
*/
public List visit(boolean isByCookie) throws Exception{
log4.info("======访问网站============cookie="+isByCookie);
String newUrls = null;
TableColumn[] arrColumns;
LinkTag lt = null;
String title, dates, codes, link;
HtmlPage page = null;
TableTag tableContent[] = null;
int order_count = 0;
List list = new LinkedList();
if(this.getUrl().startsWith("http:")){
newUrls = this.getUrl();
}
else{
if(this.base_url.endsWith("/")){
newUrls = this.base_url+"/"+this.getUrl();
}
else{
newUrls = this.base_url+this.getUrl();
}
}
// if(true){
// page = move2Urls(this.getHttpURLConnection(), newUrls);
// page.getBody().toHtml();
//// return page.getBody().toHtml();
// }
log4.info("newUrls="+newUrls);
String str = this.move2UrlsHtml(this.getHttpURLConnection(), newUrls, isByCookie);
String[] msgs = str.split("\n");
List htmls = new LinkedList();
for(String msg: msgs){
msg = msg.trim();
msg = msg.replaceAll(" ", "");
msg = msg.replaceAll("<", "");
msg = msg.replaceAll(">", "");
msg = msg.replaceAll(""", "");
msg = msg.replaceAll("td", "");
msg = msg.replaceAll("tr", "");
// msg = msg.replaceAll("&", "&");
// msg = msg.replaceAll("<", "<");
// msg = msg.replaceAll(">", ">");
// msg = msg.replaceAll("\"", """);
// msg = msg.replaceAll("'", "'");
if(!ErrorCode.isEmpty(msg)){
htmls.add(msg);
}
}
return htmls;
}