import java.util.List; public class Test { @org.junit.Test public void getDatasByClass() { Rule rule = new Rule( "http://www1.sxcredit.gov.cn/public/infocomquery.do?method=publicIndexQuery", new String[] { "query.enterprisename","query.registationnumber" }, new String[] { "兴网","" }, "cont_right", Rule.CLASS, Rule.POST); List<LinkTypeData> extracts = ExtractService.extract(rule); printf(extracts); } @org.junit.Test public void getDatasByCssQuery() { Rule rule = new Rule("http://www.11315.com/search", new String[] { "name" }, new String[] { "兴网" }, "div.g-mn div.con-model", Rule.SELECTION, Rule.GET); List<LinkTypeData> extracts = ExtractService.extract(rule); printf(extracts); } public void printf(List<LinkTypeData> datas) { for (LinkTypeData data : datas) { System.out.println(data.getLinkText()); System.out.println(data.getLinkHref()); System.out.println("***********************************"); } } }
public class RuleException extends RuntimeException { public RuleException() { super(); // TODO Auto-generated constructor stub } public RuleException(String message, Throwable cause) { super(message, cause); // TODO Auto-generated constructor stub } public RuleException(String message) { super(message); // TODO Auto-generated constructor stub } public RuleException(Throwable cause) { super(cause); // TODO Auto-generated constructor stub } }