예제 #1
0
 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);
 }
예제 #2
0
 public void forwardToWeiboPage() {
   String url = Constant.personalHomePage;
   headers.put(
       "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
   // headers.put("Accept-Encoding", "gzip, deflate, sdch");
   headers.put("Accept-Language", "zh-CN");
   headers.put(
       "User-Agent",
       "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36");
   headers.put("Connection", "Keep-Alive");
   // headers.put("Cookie", headers.get("Cookie"));
   this.headers.put("Host", "s.weibo.com");
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   responseText = EncodeUtils.unicdoeToGB2312(responseText);
   List<Cookie> cookies = HttpUtils.getResponseCookies(response);
   String cookie = HttpUtils.setCookie2String(cookies);
   // System.out.println("forward cookie:"+cookie);
   headers.put("Cookie", cookie);
 }
예제 #3
0
  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);
  }