htmlunit相当于java的一个浏览器,可以分析页面,获得页面数据
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequestSettings;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlTable;
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
final WebClient wc = new WebClient();
wc.setJavaScriptEnabled(false);
WebRequestSettings settings = new WebRequestSettings(new URL(
QUERY_FORM_URL + "&cph=" + vehicleNo + "&cx=" + vehicleColor));
settings.setCharset("gb2312");
HtmlPage page = (HtmlPage) wc.getPage(settings);
List<HtmlTable> tables = page.getDocumentHtmlElement()
.getHtmlElementsByTagName("table");
先关连接: