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 阅读(5177) 评论(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)

相册

搜索

积分与排名

最新随笔

最新评论

阅读排行榜

评论排行榜