为什么java post方法连接超时甚至它在浏览器上运行?

时间:2017-11-09 14:16:02

标签: java apache apache-httpclient-4.x

我在开发者标签上看网络(谷歌浏览器),这是ss

my_image

我想获取java应用程序的数据。

我的代码在这里:

   String urlParameters  = "tabloNo=4&yil=2017&ay=2&paraBirimi=TL&taraf=10001";

        byte[] postData = urlParameters.getBytes( StandardCharsets.UTF_8 );
        int postDataLength = postData.length;
        String request = "http://172.168.12*.15/getreport";
        URL url = new URL( request );
        HttpURLConnection conn= (HttpURLConnection) url.openConnection();           
        conn.setDoOutput(true);
        conn.setInstanceFollowRedirects(false);
        conn.setConnectTimeout(10000);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Accept", "pplication/json, text/javascript, */*; q=0.01");
//        conn.setRequestProperty("Accept-Encoding:", "gzip, deflate" );
        conn.setRequestProperty("Accept-Language", "tr,en;q=0.8" );
        conn.setRequestProperty("Content-Length", Integer.toString(postDataLength ));
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");  
        conn.setRequestProperty("Host", "ebulten.bddk.org.tr"  );
        conn.setRequestProperty("Origin","http://172.168.12*.15/");
        conn.setRequestProperty("Proxy-Connection", "keep-alive" );
        conn.setRequestProperty("Referer", "http://172.168.12*.15/" );
        conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" );
        conn.setRequestProperty("X-Requested-With","XMLHttpRequest" );
        conn.setUseCaches(true); 
        try(DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {
           wr.write( postData );
        } 

它提供连接超时:连接

注意:

它是公共网站,每个人都读取数据。我想以编程方式阅读它。

提前致谢

0 个答案:

没有答案