htmlunit解析页面

 

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");

 

先关连接:

http://htmlunit.sourceforge.net/

http://htmlparser.sourceforge.net/

你可能感兴趣的:(html,.net,浏览器)