コード例 #1
0
  public String search(String keyword, int pageNo) {

    // %25E5%25AE%2581%25E6%25B3%25A2%25E5%25A4%25A7%25E5%25AD%25A6 表示编码后的宁波大学
    String url =
        "http://s.weibo.com/weibo/%25E5%25AE%2581%25E6%25B3%25A2%25E5%25A4%25A7%25E5%25AD%25A6&page="
            + pageNo;

    /*uid是用户id;根据uid可以获取用户的基本信息,如粉丝,关注数等.
    1)如用户微博尚未设置个性域名,则用户在新浪微博的ID即是用户微博访问地址后面的数字串,
    如访问地址“http://t.sina.cn/12345678……”,则用户在新浪的微博UID为“12345678……”数字串
    2)如用户微博已设置了个性域名,则可将鼠标移至用户微博右侧显示粉丝数的链接,查看链接地址,
    链接中带上的数字串即是用户的微博UID.如 http://weibo.com/12345678.../fans?leftnav=1&wvr=4,则用户在新浪的微博UID为 “12345678……”数字串
    */
    // wvr 这个仅仅是微博的一个版本号,无关影响的.
    String cookieValue =
        "SINAGLOBAL=8556698272004.724.1417744632425; [email protected]; myuid=2283740497; wvr=6; [email protected]; _s_tentry=developer.51cto.com; SWB=usrmdinst_14; SUS=SID-5438576807-1419173757-GZ-lrze7-d8e1e3f082b428c12412c8ba30f0a6de; SUE=es%3D4cdfdd5d5f0f75141c092b32f89525a2%26ev%3Dv1%26es2%3D469e50c869315e57efeec3012c3bb6a8%26rs0%3DoWdG36CQ33LUEtKTvGn907Zy1mwFETvSVJsxeHEiaMPcKDB7pFxg596a2pLhFLJfQmswf4AvXYAkzTfemrYgWrz%252BQPustEA2wLNYufYpAZqFsGWanhTBq6elzB2yoZp41xcpy1WwXn1CuvzIzzEYpuILjHahkmJDQDQy6KaxlbA%253D%26rv%3D0; SUP=cv%3D1%26bt%3D1419173757%26et%3D1419260157%26d%3Dc909%26i%3Da6de%26us%3D1%26vf%3D0%26vt%3D0%26ac%3D27%26st%3D0%26uid%3D5438576807%26name%3Dsm2014121904%2540126.com%26nick%3DSocialMedia%25E5%259B%259B%25E5%25A8%2583%26fmp%3D%26lcp%3D; SUB=_2A255kq8tDeTxGeNK6FoU9yjEyzuIHXVa6DVlrDV8PUNbvtBeLW3TkW-bMoi0G_bBfpbS3TMqcXg6zDWFLA..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9WhGThsH46uNrx1VY0ApV0SR5JpX5KMt; ALF=1450709756; SSOLoginState=1419173757; WBStore=bc5ad8450c3f8a48|undefined; Apache=1027467835228.8901.1419173761694; ULV=1419173761704:6:6:1:1027467835228.8901.1419173761694:1418797827169; UOR=www.ilehao.com,widget.weibo.com,login.sina.com.cn; ULOGIN_IMG=14192385783486";
    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("Cache-Control", "max-age=0");
    headers.put(
        "Referer",
        "http://login.sina.com.cn/sso/login.php?url=http%3A%2F%2Fs.weibo.com%2Fweibo%2F%2525E6%252583%2525A0%2525E6%252599%2525AE%26page%3D2&_rand=1419173756.6387&gateway=1&service=weibo&entry=miniblog&useticket=1&returntype=META");
    headers.put("Cookie", cookieValue);
    this.headers.put("Host", "s.weibo.com");
    HttpResponse response = HttpUtils.doGet(url, headers);
    String responseText = HttpUtils.getStringFromResponse(response);
    responseText = EncodeUtils.unicdoeToGB2312(responseText);
    return responseText;
  }
コード例 #2
0
 /**
  * 得到的标签信息 调用一次10个
  *
  * @return
  */
 public String getTags() {
   String url = "http://account.weibo.com/set/aj/tagsuggest?__rnd=" + System.currentTimeMillis();
   this.headers.put("Referer", "http://account.weibo.com/set/tag#");
   this.headers.put("Host", "account.weibo.com");
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #3
0
  /*
   *  得到微群中微博信息 经过多次尝试成功
   *  每次获得50个微博记录,page是页号, count值50 可以在1-75之间,但是,每次开始的时候还是从50的倍数开始的
   */
  public String getGroupTopic(int page, int count, String gid) {
    this.headers.put("Referer", "http://q.weibo.com/" + gid);
    this.headers.put("Host", "q.weibo.com");
    this.headers.put("Content-Type", "application/x-www-form-urlencoded");
    this.headers.put("x-requested-with", "XMLHttpRequest");
    Integer pre_page = 1;
    if (page == 1) {
      pre_page = 2;
    } else {
      pre_page = page - 1;
    }
    Map<String, String> params = new HashMap<String, String>();
    params.put("_k", System.currentTimeMillis() + "");
    params.put("_t", "0");
    params.put("count", count + "");
    // params.put("end_id", end_id);
    params.put("gid", gid);
    params.put("is_search", "");
    params.put("key_word", "");
    params.put("me", "0");
    params.put("mids", "");
    params.put("new", "0");
    params.put("page", page + "");
    params.put("pagebar", "0"); // pagebar涓昏鏄湅鏄惁寮�濮嬪垎椤典簡
    params.put("pre_page", pre_page + "");
    params.put("since_id", "0");
    params.put("uid", "0");

    String url = "http://q.weibo.com/ajax/mblog/groupfeed";
    HttpResponse response = HttpUtils.doPost(url, headers, params);
    return HttpUtils.getStringFromResponse(response);
  }
コード例 #4
0
  private String addorcancleFollowing(String memberid, int option) {
    String url = "";
    switch (option) {
      case ADDFOLLOWING:
        url = "http://weibo.com/aj/f/followed?__rnd=" + System.currentTimeMillis();
        break;
      case CANCELFOLLOWING:
        url = "http://weibo.com/aj/f/unfollow?__rnd=" + System.currentTimeMillis();
        break;
    }

    Map<String, String> params = new HashMap<String, String>();

    this.headers.put("Referer", "http://weibo.com/");
    this.headers.put("Host", "weibo.com");
    this.headers.put("Content-Type", "application/x-www-form-urlencoded");
    this.headers.put("Referer", "http://weibo.com/");
    this.headers.put("x-requested-with", "XMLHttpRequest");

    params.put("_t", "0");
    params.put("f", "1");
    params.put("location", "profile");
    params.put("refer_flag", "");
    params.put("refer_sort", "profile");
    params.put("uid", memberid);

    HttpResponse response = HttpUtils.doPost(url, headers, params);
    return HttpUtils.getStringFromResponse(response);
  }
コード例 #5
0
 /*
  *  名人堂与达人信息
  */
 public String getVerified(String url) {
   this.headers.put("Host", "verified.weibo.com");
   this.headers.put("Referer", "http://plaza.weibo.com/?topnav=1&wvr=4");
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   return responseText;
 }
コード例 #6
0
  public String searchCommentsByUid(String uid) {

    String url = "http://www.weibo.com/u/" + uid;
    String cookieValue =
        "SINAGLOBAL=8556698272004.724.1417744632425; myuid=5438576807; wvr=6; YF-Ugrow-G0=ad06784f6deda07eea88e095402e4243; SSOLoginState=1423150079; YF-V5-G0=32eb5467e9bfc8b60c2d771056535ac5; _s_tentry=www.weibo.com; Apache=6264929557219.147.1423150103832; ULV=1423150103842:18:2:2:6264929557219.147.1423150103832:1422769721265; ULOGIN_IMG=1423233797946; YF-Page-G0=82cdcdfb16327a659fbb60cc9368fb19; SUS=SID-2035860051-1423286223-GZ-jdkh4-c8ea11de0a42151313986e52f9aa6017; SUE=es%3D8701ff5aca59244ff1ff263cf985bee6%26ev%3Dv1%26es2%3D7995c9eb7455697c09fac4f7486e14eb%26rs0%3DTyXXIRjcEw%252BeS5PaVSM%252FhQjc2JGhKBOe3uFTgShiIUAbPFI2eKtrgxM2wIi9A1xndiTFFM72zY%252FDKYFXONrgkao5cRo%252FHkydV%252FnaQjNmXoeESu5gi6Iq0aX883NhGR0utBVNZb5XaIG3X6HMMfBJC%252B7pnVHogEo8eD6cx8nzN5c%253D%26rv%3D0; SUP=cv%3D1%26bt%3D1423286223%26et%3D1423372623%26d%3Dc909%26i%3D6017%26us%3D1%26vf%3D0%26vt%3D0%26ac%3D0%26st%3D0%26uid%3D2035860051%26name%3Dshy_annan%2540126.com%26nick%3D%25E7%2594%25A8%25E6%2588%25B72035860051%26fmp%3D%26lcp%3D2013-08-18%252021%253A48%253A10; SUB=_2A2550e-fDeTxGeRO6FcZ9i7Mzj2IHXVap0ZXrDV8PUNbvtBuLWnTkW-gBGVORTA7J_lSZzAqzW6E50JjBQ..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9Wh7oKNCGYcNnhlC6eqqQbbl5JpX5KMt; SUHB=0M20OGRPiOKzyc; ALF=1454822222; UOR=www.ilehao.com,widget.weibo.com,login.sina.com.cn";
    headers.put(
        "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
    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("Cache-Control", "max-age=0");
    headers.put("Cookie", cookieValue);
    this.headers.put("Host", "www.weibo.com");
    HttpResponse response = HttpUtils.doGet(url, headers);
    String responseText = HttpUtils.getStringFromResponse(response);
    responseText = EncodeUtils.unicdoeToGB2312(responseText);

    System.out.println("searchCommentsByUid start");
    System.out.println(responseText);
    System.out.println("searchCommentsByUid end");

    return responseText;
  }
コード例 #7
0
 /*
  * 得到微群一级分类
  */
 public String getGroupCategory() {
   String url = "http://q.weibo.com/";
   this.headers.put("Host", "q.weibo.com");
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   responseText = EncodeUtils.unicdoeToGB2312(responseText);
   return responseText;
 }
コード例 #8
0
 // 用户关注的用户信息     html页面
 public String getMemberFollowing(String memberID, int page) {
   String url = "http://weibo.com/" + memberID + "/follow?page=" + page;
   this.headers.put("Host", "weibo.com");
   this.headers.put("Referer", "http://weibo.com/" + memberID + "/follow");
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   return responseText;
 }
コード例 #9
0
 // 用户粉丝用户信息    html页面,每次20个
 public String getMemberFans(String memberID, int page) {
   String url = "http://weibo.com/" + memberID + "/fans?&uid=1689219395&tag=&page=" + page;
   this.headers.put("Host", "weibo.com");
   this.headers.put("Referer", "http://weibo.com/" + memberID + "/fans");
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   return responseText;
 }
コード例 #10
0
 // 用户基本信息          主要是将要解析用户主页下方经过编码后的内容
 public String getMemberInfo(String memberID) {
   String url = "http://weibo.com/" + memberID + "/info";
   this.headers.put("Host", "weibo.com");
   this.headers.put("Referer", "http://weibo.com/u/" + memberID);
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   return responseText;
 }
コード例 #11
0
 // 得到微群管理员ID信息,其实用户成员的第一页 HTML页面
 public String getGroupAdministrator(String groupid) {
   String url = "http://q.weibo.com/" + groupid + "/members/all";
   this.headers.remove("Referer");
   this.headers.put("Host", "q.weibo.com");
   this.headers.remove("Content-Type");
   this.headers.remove("x-requested-with");
   HttpResponse response = HttpUtils.doGet(url, headers);
   String responseText = HttpUtils.getStringFromResponse(response);
   return responseText;
 }
コード例 #12
0
  // 得到微群的主页信息  HTML页码   主要是为了得到第一条微博记录的MID值
  public String getgroupMainPage(String groupid) {
    String url = "http://q.weibo.com/" + groupid + "?topnav=1";
    this.headers.remove("Referer");
    this.headers.put("Host", "q.weibo.com");
    this.headers.remove("Content-Type");
    this.headers.remove("x-requested-with");

    HttpResponse response = HttpUtils.doGet(url, headers);
    String responseText = HttpUtils.getStringFromResponse(response);
    return responseText;
  }
コード例 #13
0
 /**
  * 得到微博热词信息
  *
  * @param k :热词的门类
  */
 public String getHotWords(String k) {
   String url = "http://data.weibo.com/top/keyword?k=" + k;
   try {
     Integer.parseInt(k);
   } catch (Exception ex) {
     url = "http://data.weibo.com/top/keyword?t=" + k;
   }
   this.headers.put("Referer", "http://data.weibo.com/top/keyword");
   this.headers.put("Host", "data.weibo.com");
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #14
0
 /*
  *  得到微群中微博信息数目
  *  这个信息中其实还包含了微群的所有的基本信息~~~~~~~~~~****** json格式的数据信息
  */
 public String getGroupMessageNumber(String gid) {
   this.headers.put("Referer", "http://q.weibo.com/" + gid);
   this.headers.put("Host", "q.weibo.com");
   this.headers.put("Content-Type", "application/x-www-form-urlencoded");
   this.headers.put("x-requested-with", "XMLHttpRequest");
   String url =
       "http://q.weibo.com/ajax/rightnav/groupprofile?gid="
           + gid
           + "&_t=0&__rnd="
           + System.currentTimeMillis();
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #15
0
 /**
  * 得到微博热帖子
  *
  * @param cat 表示热帖门类
  * @param page 表示页号
  */
 public String getHotWeibo(String cat, int page) {
   String url =
       "http://data.weibo.com/hot/ajax/catfeed?page="
           + page
           + "&cat="
           + cat
           + "&_t=0&__rnd="
           + System.currentTimeMillis();
   this.headers.put("Referer", "http://data.weibo.com/hot/minibloghot");
   this.headers.put("Host", "data.weibo.com");
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #16
0
  // 得到表情列表信息
  public String getFaceList() {
    String url =
        "http://weibo.com/aj/mblog/face?type=face&_t=0&__rnd=" + System.currentTimeMillis();
    this.headers.put("Referer", "http://weibo.com/");
    this.headers.put("Host", "weibo.com");
    this.headers.put("Content-Type", "application/x-www-form-urlencoded");
    this.headers.put("x-requested-with", "XMLHttpRequest");

    HttpResponse response = HttpUtils.doGet(url, headers);
    String responseText = HttpUtils.getStringFromResponse(response);
    System.out.println(responseText);
    Utils.writeFileFromString("tmpFile/faceList.txt", responseText);
    return responseText;
  }
コード例 #17
0
 // 发布一条文字微博
 public String releaseTopic(String content) {
   this.headers.put("Referer", "http://weibo.com/");
   this.headers.put("Host", "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("location", "home");
   params.put("module", "stissue");
   params.put("pic_id", "");
   params.put("text", content);
   String url = "http://weibo.com/aj/mblog/add?__rnd=" + System.currentTimeMillis();
   HttpResponse response = HttpUtils.doPost(url, headers, params);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #18
0
  public String getDaRen(Integer page) {
    String op = "ltime"; // fans 琛ㄧず鎸夌収绮変笣鏁扮洰鎺掑垪 ltime琛ㄧず鎸夋洿鏂版椂闂存帓鍒�
    String url = "http://club.weibo.com/list?sex=3&op=" + op + "&page=" + page + "&";
    Integer pre_page = (page <= 1 ? 2 : page - 1);
    this.headers.put("Host", "club.weibo.com");
    this.headers.put("Referer", "http://club.weibo.com/list?sex=3&op=ltime&page=" + pre_page + "&");
    this.headers.remove("Content-Type");
    this.headers.remove("x-requested-with");

    HttpResponse response = HttpUtils.doGet(url, headers);
    if (response != null) {
      return HttpUtils.getStringFromResponse(response);
    }
    return "";
  }
コード例 #19
0
 /** 根据微博吧 名称 ,得到该吧内的所有帖子标题 第二步 */
 public String getWeiBarByWeibarName(String bid, int p) {
   String url =
       "http://weiba.weibo.com/aj_t/postlist?bid="
           + bid
           + "&p="
           + p
           + "&_t=all&__rnd="
           + System.currentTimeMillis();
   this.headers.put("Referer", "http://weiba.weibo.com/");
   this.headers.put("Host", "weiba.weibo.com");
   this.headers.put("Accept", "*/*");
   this.headers.put("Content-Type", "application/x-www-form-urlencoded");
   this.headers.put("X-Requested-With", "XMLHttpRequest");
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #20
0
  // 爬虫根据关键字,查询时间断,和查询页数  来得到htmlContent
  public String search(String keyword, int pageNo, String fromdate, String todate) {
    StringBuffer stringBuffer = new StringBuffer(200);
    // 宁波大学 - %25E5%25AE%2581%25E6%25B3%25A2%25E5%25A4%25A7%25E5%25AD%25A6

    // 测试时候用的
    // keyword="%25E5%25AE%2581%25E6%25B3%25A2%25E5%25A4%25A7%25E5%25AD%25A6";

    stringBuffer.append("http://s.weibo.com/weibo/" + keyword + "&page=");
    stringBuffer.append(pageNo);
    stringBuffer.append("&typeall=1&suball=1&timescope=custom:");
    stringBuffer.append(fromdate);
    stringBuffer.append(":");
    stringBuffer.append(todate);
    stringBuffer.append("&Refer=g");
    // stringBuffer.append("&scope=ori");

    // url为拼接后,最终要用这个url来在sina中搜索.
    String url = stringBuffer.toString();
    String cookieValue =
        headers.get(
            "Cookie"); // "SINAGLOBAL=8556698272004.724.1417744632425; myuid=2035860051;
                       // UOR=www.ilehao.com,widget.weibo.com,www.doc88.com; wvr=6;
                       // SUS=SID-2035860051-1423150079-GZ-piynz-c9f28711a1769c9212aba24b28f86017;
                       // SUE=es%3D8aa55aff3d74de668e06c0650147da8e%26ev%3Dv1%26es2%3Dd379acdd7f57f87a76db1e42850b9413%26rs0%3DEXf55ZsIsekO2mCCwVBK6NUvWg39VceT3eD2n65n1u16wcoi13qakdd3tO0Lcl4vsJ3a0%252BMoRLsQFY44%252FTCxHWm7whpMmzdufha%252F9aYa9RRG%252Bbh2qTtblj2xqBbtUZkZWNymxkiYD%252Bes7EzYyiCSo7UcB%252BOWnPIAvCVjXhBxVQ0%253D%26rv%3D0; SUP=cv%3D1%26bt%3D1423150079%26et%3D1423236479%26d%3Dc909%26i%3D6017%26us%3D1%26vf%3D0%26vt%3D0%26ac%3D0%26st%3D0%26uid%3D2035860051%26name%3Dshy_annan%2540126.com%26nick%3D%25E7%2594%25A8%25E6%2588%25B72035860051%26fmp%3D%26lcp%3D2013-08-18%252021%253A48%253A10; SUB=_2A2551_uvDeTxGeRO6FcZ9i7Mzj2IHXVapWpnrDV8PUNbvtBuLRnDkW-eWi1k7w8OWWE-t_uJb0Q4Owmh5w..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9Wh7oKNCGYcNnhlC6eqqQbbl5JpX5KMt; SUHB=0u5gtgJdzQeFzj; ALF=1454686075; SSOLoginState=1423150079; SWB=usrmdinst_12; _s_tentry=www.weibo.com; Apache=6264929557219.147.1423150103832; ULV=1423150103842:18:2:2:6264929557219.147.1423150103832:1422769721265; WBStore=3f8ca8cd96b39592|undefined";
    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("Cache-Control", "max-age=0");
    headers.put(
        "Referer",
        "http://s.weibo.com/weibo/%25E5%25AE%2581%25E6%25B3%25A2%25E5%25A4%25A7%25E5%25AD%25A6&typeall=1&suball=1&timescope=custom:"
            + fromdate
            + ":"
            + todate
            + "&Refer=g");
    headers.put("Cookie", cookieValue);
    this.headers.put("Host", "s.weibo.com");
    HttpResponse response = HttpUtils.doGet(url, headers);
    String responseText = HttpUtils.getStringFromResponse(response);
    responseText = EncodeUtils.unicdoeToGB2312(responseText);
    return responseText;
  }
コード例 #21
0
  // 根据微群号和页号得到群成员ID信息 -----JSON格式数据
  public String getGroupMembers(String groupid, int pagenumber) {
    this.headers.put("Referer", "http://q.weibo.com/" + groupid + "/members/all");
    this.headers.put("Host", "q.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("page", pagenumber + "");
    params.put("gid", groupid);
    params.put("query", "");
    params.put("tab", "all");
    params.put("vip", "1");
    String url = "http://q.weibo.com/ajax/members/page";
    HttpResponse response = HttpUtils.doPost(url, headers, params);
    return HttpUtils.getStringFromResponse(response);
  }
コード例 #22
0
  public String getVerifiedMember(String path, Integer g_index) {
    String url =
        "http://verified.weibo.com/aj/getgrouplist?g_index="
            + g_index
            + "&path="
            + path
            + "&_t=0&__rnd="
            + System.currentTimeMillis();
    this.headers.put("Host", "verified.weibo.com");
    this.headers.put("Referer", path);
    this.headers.put("Content-Type", "application/x-www-form-urlencoded");
    this.headers.put("x-requested-with", "XMLHttpRequest");
    HttpResponse response = HttpUtils.doGet(url, headers);
    String responseText = HttpUtils.getStringFromResponse(response);

    return responseText;
  }
コード例 #23
0
 /** 新浪微公益名单 type ="donate" type="discuss" */
 public String getWeiGongYiMember(int page, int projectID, String type) {
   String url =
       "http://gongyi.weibo.com/aj_personal_helpdata?page="
           + page
           + "&type="
           + type
           + "&project_id="
           + projectID
           + "&_t=0&__rnd="
           + System.currentTimeMillis();
   this.headers.put("Referer", "http://gongyi.weibo.com/" + projectID);
   this.headers.put("Host", "gongyi.weibo.com");
   this.headers.put("Accept", "*/*");
   this.headers.put("Content-Type", "application/x-www-form-urlencoded");
   this.headers.put("X-Requested-With", "XMLHttpRequest");
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #24
0
  /*
   * 根据分类得到微群信息
   * categroyID :分类ID号
   * pagenumber:页号
   * sort:分类方式 1 按成员人数 2按 微群博数 3按创建时间分类
   * count:每页的记录数目
   */
  public String getGroupByCategroy(int categroyID, int pagenumber, int sort, int count) {
    this.headers.put("Referer", "http://q.weibo.com/class/category/?id=" + categroyID);
    this.headers.put("Host", "q.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("page", pagenumber + "");
    params.put("id", categroyID + "");
    params.put("sort", sort + "");
    params.put("count", count + "");

    String url = "http://q.weibo.com/ajax/class/category";
    HttpResponse response = HttpUtils.doPost(url, headers, params);
    String responseText = HttpUtils.getStringFromResponse(response);
    responseText = EncodeUtils.unicdoeToGB2312(responseText);
    return responseText;
  }
コード例 #25
0
 /** 按照分类获取 微博吧名字 第一步 */
 public String getWeiBar(String ctgid, int p) {
   String sort = "post"; // sort =member 琛ㄧず鎸夌収鍏虫敞鏁伴噺鑾峰彇  =post 琛ㄧず鎸夌収 甯栧瓙鏁伴噺
   String url =
       "http://weiba.weibo.com/aj_f/CategoryList?sort="
           + sort
           + "&p="
           + p
           + "&ctgid="
           + ctgid
           + "&_t=0&__rnd="
           + System.currentTimeMillis();
   this.headers.put("Referer", "http://weiba.weibo.com/ct/" + ctgid);
   this.headers.put("Host", "weiba.weibo.com");
   this.headers.put("Accept", "*/*");
   this.headers.put("Content-Type", "application/x-www-form-urlencoded");
   this.headers.put("X-Requested-With", "XMLHttpRequest");
   HttpResponse response = HttpUtils.doGet(url, headers);
   return HttpUtils.getStringFromResponse(response);
 }
コード例 #26
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);
 }
コード例 #27
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);
 }
コード例 #28
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);
  }
コード例 #29
0
 // 获得用户发布的微博信息   json格式的数据
 public String getMemberReleaseTopic(
     String memberID, String end_id, Integer page, Integer pagebar) {
   String url = "";
   Integer pre_page = 1;
   Integer count = 0;
   String k = System.currentTimeMillis() + "" + (int) (Math.random() * 100000) % 100;
   if (end_id == null) {
     count = 50;
     if (page == 1) {
       pre_page = 2;
     } else {
       pre_page = page - 1;
     }
     url =
         "http://weibo.com/aj/mblog/mbloglist?"
             + "page="
             + page
             + "&count="
             + count
             + "&pre_page="
             + pre_page
             + "&"
             + "_k="
             + k
             + "&uid="
             + memberID
             + "&_t=0&__rnd="
             + System.currentTimeMillis();
   } else {
     count = 15;
     pre_page = page;
     url =
         "http://weibo.com/aj/mblog/mbloglist?"
             + "page="
             + page
             + "&count="
             + count
             + "&max_id="
             + end_id
             + "&"
             + "pre_page="
             + pre_page
             + "&end_id="
             + end_id
             + "&"
             + "pagebar="
             + pagebar
             + "&_k="
             + k
             + "&"
             + "uid="
             + memberID
             + "&_t=0&__rnd="
             + System.currentTimeMillis();
   }
   String cookieValue =
       "SINAGLOBAL=8556698272004.724.1417744632425; [email protected]; myuid=5439352084; YF-Ugrow-G0=4703aa1c27ac0c4bab8fc0fc5968141e; SSOLoginState=1421374583; wvr=6; YF-V5-G0=8c4aa275e8793f05bfb8641c780e617b; _s_tentry=login.sina.com.cn; Apache=2461283528245.9854.1421374588453; ULV=1421374588550:13:5:3:2461283528245.9854.1421374588453:1421210767499; UOR=www.ilehao.com,widget.weibo.com,login.sina.com.cn; SUS=SID-2035860051-1421462085-GZ-7jcgb-1539d643bae5195fb7f792b2ae77befb; SUE=es%3Df15e11ed09b6a0108a28adfa58609b78%26ev%3Dv1%26es2%3Da0f706efac5c89495062648a4de3e337%26rs0%3DZBxlOUv0mhmxyHfOVmZ3tH7tNvAp08BjPeLUJPdu9WzG38Dsm40px%252Bd9w21ycDpZQwBK3q0prFfNs%252F8ZuZSasa1eps%252FOGNxJ3CIHN8JN%252Fik6gVpIPgVeeRdalNWTIbth6hLa34uOp%252BXii%252Bxeib%252BvINsr%252FdOvQx6kjp6fsC44QXc%253D%26rv%3D0; SUP=cv%3D1%26bt%3D1421462085%26et%3D1421548485%26d%3Dc909%26i%3Dbefb%26us%3D1%26vf%3D0%26vt%3D0%26ac%3D2%26st%3D0%26uid%3D2035860051%26name%3Dshy_annan%2540126.com%26nick%3D%25E7%2594%25A8%25E6%2588%25B72035860051%26fmp%3D%26lcp%3D2013-08-18%252021%253A48%253A10; SUB=_2A255vboVDeTxGeRO6FcZ9i7Mzj2IHXVazdpdrDV8PUNbvtBuLVj-kW91jmbQSGo7Rn30RVvGP5KOgBgNgQ..; SUBP=0033WrSXqPxfM725Ws9jqgMF55529P9D9Wh7oKNCGYcNnhlC6eqqQbbl5JpX5KMt; ALF=1452998078; ULOGIN_IMG=14214638933178; YF-Page-G0=0acee381afd48776ab7a56bd67c2e7ac";
   headers.put("Cookie", cookieValue);
   this.headers.put("Referer", "http://weibo.com/u/" + memberID);
   this.headers.put("Host", "www.weibo.com");
   this.headers.put("Content-Type", "application/x-www-form-urlencoded");
   this.headers.put("x-requested-with", "XMLHttpRequest");
   url = "http://weibo.com/u/" + memberID;
   HttpResponse response = HttpUtils.doGet(url, headers);
   if (response == null) {
     return "";
   }
   return HttpUtils.getStringFromResponse(response);
 }