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 閱讀(5213) 評論(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)

          相冊

          搜索

          積分與排名

          最新隨筆

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 裕民县| 白城市| 哈尔滨市| 奈曼旗| 行唐县| 阿坝| 武功县| 钟祥市| 应用必备| 乐山市| 杂多县| 扎赉特旗| 华宁县| 潞西市| 图木舒克市| 鹿邑县| 兴城市| 宿松县| 闽清县| 来凤县| 宁明县| 樟树市| 泌阳县| 星座| 来宾市| 宁津县| 明水县| 花莲市| 原阳县| 宜兴市| 来宾市| 大同市| 青铜峡市| 保康县| 榆社县| 资中县| 加查县| 青岛市| 从化市| 任丘市| 云梦县|