簡體   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