在JAVA中用HttpConnection可以很容易地实现。本站尚未实践,有需要可以测试一下。
public static void main(String[] args ,String urlStr) { HttpClient client; client = new HttpClient(new MultiThreadedHttpConnectionManager()); client.getHttpConnectionManager().getParams().setConnectionTimeout(10000); client.getParams().setParameter(HttpMethodParams.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)"); //让服务器认为是IE GetMethod get = new GetMethod(urlStr); get.setFollowRedirects(false); //禁止自动重定向 try { int iGetResultCode = client.executeMethod(get); String _refer = get.getResponseHeader("location").getValue(); //打印地址 GetMethod get2 = new GetMethod(URLDecoder.decode(_refer.split("tu=")[1])); get2.addRequestHeader("Referer", _refer); get2.setFollowRedirects(false); //禁止自动重定向 int iGetResultCode2 = client.executeMethod(get2); String realUrl = get2.getResponseHeader("location").getValue(); //打印地址 System.out.println("REAL URL: "+realUrl); GetMethod get3 = new GetMethod(realUrl); int iGetResultCode3 = client.executeMethod(get3); String responseBody = get3.getResponseBodyAsString(); System.out.println("Response Body: "+responseBody); System.out.println(responseBody.substring(responseBody.indexOf("sellerRate=" + "")+12,responseBody.indexOf("&", responseBody.indexOf("sellerRate=")))); } catch (Exception ex) { ex.printStackTrace(); } finally { get.releaseConnection(); } }