繁体   English   中英

如何使用Ajax从网页上使用httpclient 4.3.x获取信息

[英]how to use httpclient 4.3.x grabbing infomation from web page with ajax

例如,从https://play.google.com/store/apps获取全部内容

我发现它发布了数据:

“开始= 15&num = 5&numChildren = 10pagTok = CA8QDxjh2ND3psHQ4pcB%3AS%3AANO1ljLBy5U&ipf = 1&xhr = 1”

显示下一个浏览器页面,然后我用

  HttpPost httpPost = new HttpPost("https://play.google.com/store/apps");
  List<NameValuePair> params = new ArrayList<NameValuePair>();
    params.add(new BasicNameValuePair("start","15"));
    params.add(new BasicNameValuePair("num","5"));
    params.add(new BasicNameValuePair("numChildren","10"));
    params.add(new BasicNameValuePair("pagTok","CA8QDxjh2ND3psHQ4pcB"));
    params.add(new BasicNameValuePair("ipf","1"));
    params.add(new BasicNameValuePair("xhr","1"));

    httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
    CloseableHttpResponse response = getSSLHttpClient().execute(httpPost);
    HttpEntity entity = response.getEntity();
    try {
        if(entity != null) {
            return EntityUtils.toString(entity);
        }
    } finally {
        EntityUtils.consume(entity);
        response.close();
    }

但是最后我无法从googleplay获取网络文档,结果是一些javascript,怎么了?

Apache HTTP Client用于获取页面内容。 如果您需要在此页面上执行javascript,则可以使用HtmlUnit 是一个例子

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM