??????????????httpClient???NameValuePair?????post???????????“?????:HTTP/1.1 400 Bad Request”?????response??????????????δ????
?????????????????????????
????????????????????μ?????
HttpPost httpPost = new HttpPost(path);
httpPost.addHeader("Accept"??"text/javascript?? text/html?? application/xml?? text/xml");
httpPost.addHeader("Accept-Charset"?? "GBK??utf-8;q=0.7??*;q=0.3");
httpPost.addHeader("Accept-Encoding"?? "gzip??deflate??sdch");
httpPost.addHeader("Connection"?? "Keep-Alive");
httpPost.addHeader("Cache-Control"?? "no-cache");
httpPost.addHeader("Content-Type"?? "application/x-www-form-urlencoded");
???????????????????????д???html??????????????????????????result?е?data-coid?????????У?顣
{"msg":"succeed"??"result":{"collectHtml":"        <div class="collect-item f-fl" data-coid="33628">             <a href="/detail/favorite/33628" target="_blank">             <div class="collect-wrap f-fl">                 <div class="collect-title f-toe">                     <span>API: Edit G list</span>                 </div>                 <div class="collect-image">                     <img class="collect-i" src="                         http://acs.nosdn.127.net/15e4c8419e994e74a60186f8969b266c.jpeg?imageView&type=png&enlarge=1&quality=100&axis=0&thumbnail=190y190                             ">                     <div class="collect-number">1</div>                 </div>                 <div class="collect-guanzhu">                     <img src="/src/image/homePage/guanzhu.jpg?7f14d069d28438c6b7feeab00c2a9448">                     <span>0????</span>                 </div>             </div>             </a>         </div> "??"isAll":true}??"code":200}
?????????????
????1. ???elments
?????????????http?????response??????json??????????????JSONObject response??
???????JSONObject result = response.getJSONObject("result");?????result???????
????String collectHtml = result.getString("collectHtml");?????collectHtml?????
???????Jsoup??collectHtml???з?????
Document doc = Jsoup.parse(collectHtml?? "UTF-8");
Elements g_lists = doc.getElementsByClass("collect-item");
String g_list_id = "";
for (Element g_list:g_lists){
g_list_id = g_list.attributes().get("data-coid").trim();
logger.info(g_list_id);
}
}
????2. ???select
doc = Jsoup.parse(response?? "UTF-8");
setting_nick = doc.select("div.username").text().trim();
logger.info(setting_nick);