public SpiderSina(LoginSina ls) { this.ls = ls; this.headers = new HashMap<String, String>(); headers.put("Accept", "text/html, application/xhtml+xml, */*"); headers.put("Accept-Language", "zh-cn"); headers.put( "User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN"); headers.put("Connection", "Keep-Alive"); headers.put("Cache-Control", "no-cache"); String cookieValue = HttpUtils.setCookie2String(ls.getCookies()); headers.put("Cookie", cookieValue); }
public String setArea(Integer provinceID) { this.headers.put("Referer", "http://club.weibo.com/list"); this.headers.put("Host", "club.weibo.com"); this.headers.put("Content-Type", "application/x-www-form-urlencoded"); this.headers.put("x-requested-with", "XMLHttpRequest"); Map<String, String> params = new HashMap<String, String>(); params.put("_t", "0"); params.put("city", "1000"); params.put("prov", provinceID + ""); String url = "http://club.weibo.com/ajax_setArea.php"; HttpResponse response = HttpUtils.doPost(url, headers, params); List<Cookie> cks = HttpUtils.getResponseCookies(response); List<Cookie> cookies = ls.getCookies(); cookies.addAll(cks); String cookieValue = HttpUtils.setCookie2String(cookies); this.headers.put("Cookie", cookieValue); return HttpUtils.getStringFromResponse(response); }