`
security
  • 浏览: 379678 次
  • 来自: www.pgp.org.cn
社区版块
存档分类
最新评论

获取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();
        }

    }

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics