con.getOutputStream() 抛出数组越界异常?

图片说明

写爬虫建议用python写,java毕竟优势不在爬虫!

    /***
     * 获取文章的内容
     * 从新浪的网页分析,通过文章body的id就可以拿到相应的文章内容..
     * @param url
     * @return
     */
    public static String getNewsContent(String url) throws Exception{
        Document doc=Jsoup.parse(new URL(url), 3000);
        if(doc!=null){
            String artibody=doc.getElementById("artibody").html();//通过网页的html的id去拿到新闻内容artibody
            return artibody;
        }else{
            return "网络异常";
        }
    }

数据量太大,可能缓冲区满了导致的,建议将异常栈贴出来

语句有些繁琐,数据量大,运行不好

try {
DataOutputStream wr = new DataOutputStream(httpConn.getOutputStream());
wr.write(postData);
wr.flush();
wr.close();
} catch (Exception e) {
result.put("success", false);
result.put("error", e.getMessage());
return Pair.of(false, getJsonFromMap(result).toString());
}