David.Turing's blog

           

          獲取PDABase.com所有下載文件的HTTPClient代碼

          最近追Friends(老友記),想在PPC上看,順便編寫(xiě)了一個(gè)HTTPClient的Sample,可以獲取PDABase.com的所有下載鏈接,希望對(duì)PDA愛(ài)好者有所幫助,可以自己生成Flashget的Task,一次性Download整個(gè)網(wǎng)站。

          package ?org.apache.commons.httpclient;

          import ?java.io.IOException;
          import ?org.apache.commons.httpclient.methods.GetMethod;

          /** ?
          ???
          @author ?by?david.turing
          ???security.blogjava.net
          ???www.pgp.org.cn
          *
          */


          public ? class ?PDABase? {

          ????
          public ? static ? void ?main(String[]?args)? {

          ????????HttpClient?client?
          = ? new ?HttpClient();
          ????????client.getHostConfiguration().setHost(
          " www.pdabase.com " ,? 80 ,? " http " );
          ????????GetMethod?method?
          = ?? new ?GetMethod();
          ????????String?x?
          = ? null ;
          ????????
          int ?start = 0 ;
          ????????
          int ?end = 25000;
          ????????
          try?{
          ????????????
          ????????????
          for?(int?i?=start;?i?<?end;?i++)?{
          //????????????????method?=?new?GetMethod("/download/SoftDown.asp?ID=1000"?+?i);
          ????????????????
          ????????????????method.setPath(
          "/download/SoftDown.asp?ID="?+(10000+?i));
          ????????????????method.setRequestHeader(
          "Cookie",
          ????????????????????????
          "ASPSESSIONIDQQRRRDRR=IACDBGAAMNMOCCBIFADECAJL");
          ????????????????client.executeMethod(method);
          ????????????????
          if(method.getStatusLine().getStatusCode()==200)
          ????????????????
          {????????????????????
          ????????????????????String?response?
          =?method.getResponseBodyAsString();

          ????????????????????
          if?(response?!=?null)?{
          ????????????????????????
          if(response.indexOf("ftp")>0&&response.indexOf("zip")>0)
          ????????????????????????
          {
          ????????????????????????????
          if?((x?=?response.substring(response.indexOf("ftp"),
          ????????????????????????????????????response.indexOf(
          "zip")))?!=?null)?{
          ????????????????????????????????System.out.println(StringUtils.iso2gb(x)
          +"zip");????????????????????????
          ????????????????????????????}

          ????????????????????????}

          ????????????????????????
          else?if(response.indexOf("ftp")>0&&response.indexOf("rar")>0)
          ????????????????????????
          {
          ????????????????????????????
          if?((x?=?response.substring(response.indexOf("ftp"),
          ????????????????????????????????????response.indexOf(
          "rar")))?!=?null)?{
          ????????????????????????????????System.out.println(StringUtils.iso2gb(x)
          +"rar");????????????????????????
          ????????????????????????????}

          ????????????????????????}

          ????????????????????????
          else?if(response.indexOf("ftp")>0&&response.indexOf("exe")>0)
          ????????????????????????
          {
          ????????????????????????????
          if?((x?=?response.substring(response.indexOf("ftp"),
          ????????????????????????????????????response.indexOf(
          "exe")))?!=?null)?{
          ????????????????????????????????System.out.println(StringUtils.iso2gb(x)
          +"exe");????????????????????????
          ????????????????????????????}

          ????????????????????????}

          ????????????????????}

          ????????????????}

          ????????????}

          ????????????method.releaseConnection();
          ????????}
          ?catch?(HttpException?e)?{
          ????????????e.printStackTrace();
          ????????}
          ?catch?(IOException?e)?{
          ????????????e.printStackTrace();
          ????????}

          ????}

          }

          posted on 2006-11-13 23:18 david.turing 閱讀(5227) 評(píng)論(7)  編輯  收藏 所屬分類: 即學(xué)即用

          評(píng)論

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼 2007-03-23 08:50 zhili

          大話西游  回復(fù)  更多評(píng)論   

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼 2007-11-08 22:47 hanmei

          不知道怎么用啊。。。
          能否把用法說(shuō)下
          謝謝~  回復(fù)  更多評(píng)論   

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼 2007-11-18 16:16 barry

          i want it......  回復(fù)  更多評(píng)論   

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼 2007-11-18 16:17 barry

          iiiiiiiiiiii wany it............  回復(fù)  更多評(píng)論   

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼[未登錄](méi) 2008-07-14 15:02 yoyo

          不明白,估計(jì)他自己也不明白自己在胡說(shuō)些什么  回復(fù)  更多評(píng)論   

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼 2008-09-22 17:56 xx

          哈哈,哦明白 msn: geshuai@gmail.com  回復(fù)  更多評(píng)論   

          # re: 獲取PDABase.com所有下載文件的HTTPClient代碼 2009-02-25 10:41 wangdong

          不明白,估計(jì)他自己也不明白自己在胡說(shuō)些什么  回復(fù)  更多評(píng)論   

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(110)

          我參與的團(tuán)隊(duì)

          隨筆分類(126)

          隨筆檔案(155)

          文章分類(9)

          文章檔案(19)

          相冊(cè)

          搜索

          積分與排名

          最新隨筆

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 庆阳市| 镇江市| 大足县| 轮台县| 岳阳市| 句容市| 富锦市| 锦屏县| 濉溪县| 双柏县| 广灵县| 郑州市| 安塞县| 正镶白旗| 古丈县| 金平| 张家界市| 景谷| 衡水市| 郯城县| 长乐市| 洪泽县| 广灵县| 康马县| 得荣县| 驻马店市| 枝江市| 任丘市| 巴楚县| 册亨县| 大余县| 嘉定区| 昌吉市| 靖江市| 县级市| 静安区| 临澧县| 仁怀市| 固原市| 集安市| 湘潭市|