我可以通過InetAddress
像上面發送一個Http GET請求。如何用HtmlUnit中的inetAddress發送請求?
HttpParams params = new BasicHttpParams();
params.setParameter(ConnRoutePNames.LOCAL_ADDRESS, InetAddress.getByName(interfaceIp));
HttpClient httpClient = new DefaultHttpClient(params);
HttpGet httpGet = new HttpGet(baseUrl);
response = httpClient.execute(httpGet);
但我想通過HtmlUnit
嘗試。有沒有辦法呢?
編輯:
我試試這個:
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(baseurl);
page.getTitleText();
看到這個http://stackoverflow.com/questions/9354099/how-to -get-a-html-page-using-htmlunit –
謝謝,但我不試試這個,我不得不用特定的接口ip發送請求。 –