获取PDABase.com所有下载文件的HTTPClient代码

最近追Friends(老友记),想在PPC上看,顺便编写了一个HTTPClient的Sample,可以获取PDABase.com的所有下载链接,希望对PDA爱好者有所帮助,可以自己生成Flashget的Task,一次性Download整个网站。

None.gif package  org.apache.commons.httpclient;
None.gif
None.gif
import  java.io.IOException;
None.gif
import  org.apache.commons.httpclient.methods.GetMethod;
None.gif
ExpandedBlockStart.gifContractedBlock.gif
/** */ /**  
InBlock.gif   
@author  by david.turing
InBlock.gif   security.blogjava.net
InBlock.gif   www.pgp.org.cn
ExpandedBlockEnd.gif*
*/

None.gif
ExpandedBlockStart.gifContractedBlock.gif
public   class  PDABase  dot.gif {
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
public   static   void  main(String[] args)  dot.gif {
InBlock.gif
InBlock.gif        HttpClient client 
=   new  HttpClient();
InBlock.gif        client.getHostConfiguration().setHost(
" www.pdabase.com " 80 " http " );
InBlock.gif        GetMethod method 
=    new  GetMethod();
InBlock.gif        String x 
=   null ;
InBlock.gif        
int  start = 0 ;
InBlock.gif        
int  end = 25000;
ExpandedSubBlockStart.gifContractedSubBlock.gif        
try dot.gif{
InBlock.gif            
ExpandedSubBlockStart.gifContractedSubBlock.gif            
for (int i =start; i < end; i++dot.gif{
InBlock.gif
//                method = new GetMethod("/download/SoftDown.asp?ID=1000" + i);
InBlock.gif
                
InBlock.gif                method.setPath(
"/download/SoftDown.asp?ID=" +(10000+ i));
InBlock.gif                method.setRequestHeader(
"Cookie",
InBlock.gif                        
"ASPSESSIONIDQQRRRDRR=IACDBGAAMNMOCCBIFADECAJL");
InBlock.gif                client.executeMethod(method);
InBlock.gif                
if(method.getStatusLine().getStatusCode()==200)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{                    
InBlock.gif                    String response 
= method.getResponseBodyAsString();
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
if (response != nulldot.gif{
InBlock.gif                        
if(response.indexOf("ftp")>0&&response.indexOf("zip")>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
if ((x = response.substring(response.indexOf("ftp"),
ExpandedSubBlockStart.gifContractedSubBlock.gif                                    response.indexOf(
"zip"))) != nulldot.gif{
InBlock.gif                                System.out.println(StringUtils.iso2gb(x)
+"zip");                        
ExpandedSubBlockEnd.gif                            }

ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else if(response.indexOf("ftp")>0&&response.indexOf("rar")>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
if ((x = response.substring(response.indexOf("ftp"),
ExpandedSubBlockStart.gifContractedSubBlock.gif                                    response.indexOf(
"rar"))) != nulldot.gif{
InBlock.gif                                System.out.println(StringUtils.iso2gb(x)
+"rar");                        
ExpandedSubBlockEnd.gif                            }

ExpandedSubBlockEnd.gif                        }

InBlock.gif                        
else if(response.indexOf("ftp")>0&&response.indexOf("exe")>0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                        
dot.gif{
InBlock.gif                            
if ((x = response.substring(response.indexOf("ftp"),
ExpandedSubBlockStart.gifContractedSubBlock.gif                                    response.indexOf(
"exe"))) != nulldot.gif{
InBlock.gif                                System.out.println(StringUtils.iso2gb(x)
+"exe");                        
ExpandedSubBlockEnd.gif                            }

ExpandedSubBlockEnd.gif                        }

ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            method.releaseConnection();
ExpandedSubBlockStart.gifContractedSubBlock.gif        }
 catch (HttpException e) dot.gif{
InBlock.gif            e.printStackTrace();
ExpandedSubBlockStart.gifContractedSubBlock.gif        }
 catch (IOException e) dot.gif{
InBlock.gif            e.printStackTrace();
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值