2011-12-10 95 views
0

我在查詢一個基本上是.png圖像目錄的網頁。但它也與其他一些事物混合在一起..這是響應開始的一個示例。限制ASIHTTPRequest字符串

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> 
<html> 
<head> 
    <title>Index of /IcePics/ob</title> 
</head> 
<body> 
<h1>Index of /IcePics/ob</h1> 
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr><tr><th colspan="5"><hr></th></tr> 
<tr><td valign="top"><img src="/icons/back.gif" alt="[DIR]"></td><td><a href="/IcePics/">Parent Directory</a></td><td>&nbsp;</td><td align="right"> - </td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a0eba60-1341a12aeee.ImgPlayer0.png">1c91-1341a0eba60-1341a12aeee.ImgPlayer0.png</a></td><td align="right">07-Dec-2011 19:51 </td><td align="right">2.3K</td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a0eba60-1341a12aeee.ImgPlayer0.png.peer">1c91-1341a0eba60-1341a12aeee.ImgPlayer0.png.peer</a></td><td align="right">07-Dec-2011 19:51 </td><td align="right"> 0 </td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a0eba60-1341a12aeee.ImgPlayerBOP.png">1c91-1341a0eba60-1341a12aeee.ImgPlayerBOP.png</a></td><td align="right">07-Dec-2011 19:56 </td><td align="right">2.7K</td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a0eba60-1341a12aeee.ImgPlayerBOP.png.peer">1c91-1341a0eba60-1341a12aeee.ImgPlayerBOP.png.peer</a></td><td align="right">07-Dec-2011 19:56 </td><td align="right"> 0 </td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a0eba60-1341a12aeee.gif">1c91-1341a0eba60-1341a12aeee.gif</a></td><td align="right">07-Dec-2011 19:51 </td><td align="right"> 14K</td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a0eba60-1341a12aeee.gif.peer">1c91-1341a0eba60-1341a12aeee.gif.peer</a></td><td align="right">07-Dec-2011 19:51 </td><td align="right"> 0 </td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a00fec0-1341a050a6e.ImgPlayer0.png">1c91-1341a00fec0-1341a050a6e.ImgPlayer0.png</a></td><td align="right">07-Dec-2011 19:37 </td><td align="right">2.4K</td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a00fec0-1341a050a6e.ImgPlayer0.png.peer">1c91-1341a00fec0-1341a050a6e.ImgPlayer0.png.peer</a></td><td align="right">07-Dec-2011 19:37 </td><td align="right"> 0 </td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a00fec0-1341a050a6e.ImgPlayerBOP.png">1c91-1341a00fec0-1341a050a6e.ImgPlayerBOP.png</a></td><td align="right">07-Dec-2011 19:38 </td><td align="right">2.8K</td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a00fec0-1341a050a6e.ImgPlayerBOP.png.peer">1c91-1341a00fec0-1341a050a6e.ImgPlayerBOP.png.peer</a></td><td align="right">07-Dec-2011 19:38 </td><td align="right"> 0 </td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a00fec0-1341a050a6e.gif">1c91-1341a00fec0-1341a050a6e.gif</a></td><td align="right">07-Dec-2011 19:37 </td><td align="right"> 13K</td></tr> 
<tr><td valign="top"><img src="/icons/image2.gif" alt="[IMG]"></td><td><a href="1c91-1341a00fec0-1341a050a6e.gif.peer">1c91-1341a00fec0-1341a050a6e.gif.peer</a></td><td align="right">07-Dec-2011 19:37 </td><td align="right"> 0 </td></tr> 

我只是在.png圖像之後。這是我如何獲得信息atm。

#pragma ASIHTTPRequest Delegates 

- (IBAction)sendHttpsRequest 
{ 
    //Start HUD 
    // [SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack]; 
    // [SVProgressHUD setStatus:@"loading..."]; 

    //Set request address 
    NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"http://www.metservice.com/IcePics/ob"]; 

    //call ASIHTTP delegates (Used to connect to database) 
    NSURL *url = [NSURL URLWithString:databaseURL]; 

    //This sets up all other request 
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; 

    [request setDelegate:self]; 
    [request startAsynchronous]; 
} 

- (void)requestFinished:(ASIHTTPRequest *)request 
{  
    NSString *responseString = [[NSString alloc] init]; 

    responseString = [request responseString]; //Pass requested text from server over to NSString 
    NSLog(@"Response String = %@", responseString); 

    //removies the SVProgressHUD 
    [NSTimer scheduledTimerWithTimeInterval:0.25 target:self selector:@selector(stopAnimating) userInfo:nil repeats:NO]; 
} 

- (void)requestFailed:(ASIHTTPRequest *)request 
{ 
    NSError *error = [request error]; 
    NSLog(@"%@", error); 
} 

所以問題真的仍然是如何只得到.png圖像。我是否通過NSXMLParser謂詞做到這一點?如果是的話,你可以提供謂詞的一些示例代碼。

這將是巨大的讚賞

回答

1

看看ASIWebPageRequest - 它擁有幾乎所有你需要已有的代碼,你只需要切出一些代碼來處理下載CSS等

+0

好吧,現在好好的閱讀。我有一天掠過它,但認爲它不會幫助我..所以時間非常感謝。 –