0

我正在通过网络服务调用 HTML 页面。我需要获取 HTML 页面的漏洞源代码。我的问题是,当我将 http 响应转换为字符串时,我只得到 HTML 页面的一部分。我怎样才能得到洞 HTML 页面。请帮帮我。

//paramString1 = url,paramString = header, paramList = paramiters
public String a(String paramString1, String paramString2, List paramList)
  {
    String str1 = null; 
    HttpPost localHttpPost = new HttpPost(paramString1);
    localHttpPost.addHeader("Accept-Encoding", "gzip");
    InputStream localInputStream = null;
   try
     {

    localHttpPost.setEntity(new UrlEncodedFormEntity(paramList));
    localHttpPost.setHeader("Referer", paramString2);
    HttpResponse localHttpResponse = this.c.execute(localHttpPost);
    int i = localHttpResponse.getStatusLine().getStatusCode();

    localInputStream = localHttpResponse.getEntity().getContent();
    Header localHeader = localHttpResponse.getFirstHeader("Content-Encoding");
    if ((localHeader != null) && (localHeader.getValue().equalsIgnoreCase("gzip")))
    {
         GZIPInputStream localObject = null;
      localObject = new GZIPInputStream(localInputStream);
      Log.d("API", "GZIP Response decoded!");
      BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader((InputStream)localObject, "UTF-8"));
      StringBuilder localStringBuilder = new StringBuilder();
      while(true){
          String str2 = localBufferedReader.readLine();
          if (str2 == null)
            break;
          localHttpResponse.getEntity().consumeContent();
          str1 = localStringBuilder.toString();
          localStringBuilder.append(str2);
          continue;
      }
    }
  }
  catch (IOException localIOException)
  {
    localHttpPost.abort();

  }
  catch (Exception localException)
  {
    localHttpPost.abort();

  }
  Object localObject = localInputStream;

return (String)str1;
4

2 回答 2

0

您是否在变量 paramString1 中接收 HTML?在这种情况下,您是以某种方式对字符串进行编码还是只是平面 HTML?

也许 HTML 特殊字符正在破坏您的响应。尝试在服务器端使用 urlSafe Base64 对字符串进行编码,并在客户端对其进行解码:

您可以使用 Apache Commons 的 Base64 函数。

服务器端:

Base64 encoder = new Base64(true);
encoder.encode(yourBytes);

客户端:

Base64 decoder = new Base64(true);
byte[] decodedBytes = decoder.decode(paramString1);
HttpPost localHttpPost = new HttpPost(new String(decodedBytes));
于 2013-06-17T10:57:26.993 回答
0

您可能无法在您的 stringBuilder 中获得完整的源代码,因为它必须超过 stringBuilder 的最大大小,就像StringBuilder数组集一样。如果你想存储那个特定的源代码。你可以试试这个:inputStream(包含html源代码)数据,直接存储到一个文件中。然后您将在该文件中拥有完整的源代码,然后对您需要的任何内容执行文件操作。看看这是否可以帮助你。

于 2013-06-17T14:38:00.440 回答