一、獲取http請求的內容,無需cookie類型的。json
String URL="http://www.baidu.com";
Document doc=Jsoup.connect(url).get()
二、若是返回的字段是Json串的String類型,例如Ajax請求,使用上用的方法會拋出異常。須要使用另外一個方法。api
String url="https://www.baidu.com/feed/api/tab/gettabinfo?pd=wise&sid=114748_100185_116351_114744_103342_110773_114243_107312_116647_115864_116477_114798_116094_116310_115534_115446_116387_116204_115351_114276_116412_110085&ssid=0&from=844b&pu=sz%25401320_2001%252Cta%2540iphone_1_9.1_3_601&qid=2505421101&ms=1&_=1496198521868" String str= Jsoup.connect(url).ignoreContentType(true).execute().body();
三、String 轉換成List<Object>數組
// 轉換成對象數組 String jsonstring2 = "[{\"a\":51,\"b\":0}]"; Usa[] usa2 = JSON.parseObject(jsonstring2, new TypeReference<Usa[]>(){}); List list = Arrays.asList(usa2);
四、正則匹配cookie
String[] qiandao = doc.toString().split("簽到"); String regex = "(\\d+)"; Pattern pattern = Pattern.compile(regex); Matcher matcher1 = pattern.matcher(qiandao[3]); matcher1.find(); member.setQiandao(matcher1.group());