David.Turing's blog

           

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

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

          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 閱讀(5212) 評論(7)  編輯  收藏 所屬分類: 即學即用

          評論

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

          大話西游  回復  更多評論   

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

          不知道怎么用啊。。。
          能否把用法說下
          謝謝~  回復  更多評論   

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

          i want it......  回復  更多評論   

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

          iiiiiiiiiiii wany it............  回復  更多評論   

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

          不明白,估計他自己也不明白自己在胡說些什么  回復  更多評論   

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

          哈哈,哦明白 msn: geshuai@gmail.com  回復  更多評論   

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

          不明白,估計他自己也不明白自己在胡說些什么  回復  更多評論   

          導航

          統計

          常用鏈接

          留言簿(110)

          我參與的團隊

          隨筆分類(126)

          隨筆檔案(155)

          文章分類(9)

          文章檔案(19)

          相冊

          搜索

          積分與排名

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 濉溪县| 沙田区| 亳州市| 锦屏县| 进贤县| 玛沁县| 东安县| 科尔| 三台县| 克什克腾旗| 永昌县| 满城县| 含山县| 连州市| 阿勒泰市| 威宁| 镶黄旗| 连平县| 麻栗坡县| 云南省| 凤城市| 巴里| 华坪县| 连平县| 文昌市| 宁都县| 张家川| 德令哈市| 石河子市| 慈利县| 绥芬河市| 中卫市| 广水市| 玉门市| 齐河县| 海淀区| 汝阳县| 炎陵县| 洛扎县| 格尔木市| 宁武县|