Android&Java解析JS

private void parseHtml() throws Exception {

        new Thread(new Runnable() {
            @Override
            public void run() {
                String s = "http://xinjinqiao.tprtc.com/admin/main/pro!lrprolist.do";

                try {
                    URL url = new URL(s);
                    HttpURLConnection http = (HttpURLConnection) url.openConnection();
                    http.setDoOutput(true);
                    http.setDoInput(true);
                    http.setRequestMethod("POST");
                    http.connect();
                    OutputStreamWriter out = new OutputStreamWriter(http.getOutputStream(), "UTF-8");

                    // 添加POST请求的参数 格式:A=A&B+B
                    String input = "name=flr&nowpage=1&pagesize=10";

                    out.append(input);
                    out.flush();
                    out.close();
                    int length = (int) http.getContentLength();
                    System.out.println(length);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(http.getInputStream()));
                    String line;
                    StringBuffer buffer = new StringBuffer();
                    while ((line = reader.readLine()) != null) {
                        buffer.append(line);
                    }
                    reader.close();
                    http.disconnect();
                    System.out.println(buffer.toString());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

你可能感兴趣的:(手机端)