开发者

How can I pull HTML code into an NSString from an iOS app?

I am trying to pull down the code from an HTML website that ha开发者_开发百科s no more than 2 lines on it. The code contains a word that I need to retrieve. Is there a simple way to pull down that code and put it in an NSString?

Further details: I am going to have an app that checks for a word on a page. If that word is what I am looking for, the app will show the text "confirmed". The purpose of the app is to check to see if the page is accessible.


If you need a http library to hit the server try asihttp. Apart from this i need more info of what you are trying to do...


If you just want to check if that website is reachable, you can go with HTTP Success Status Codes.

Using ASIHTTPRequest simplifies communication over the web.


If you still want to evaluate the text on that website, can also just retrieve it using:

[request responseString];

Depending on what you get from the website, it's up to you how to update the UI.


Just change the link between the quotes and it'll work!

-(void) viewDidLoad {     
    NSString * sFeedURL = [NSString stringWithFormat:@"http://www.google.com/ig/api?weather=,,,270000,960000"];
 //RSS Feed URL goes between quotes
  NSString * sActualFeed = [NSString stringWithContentsOfURL:[NSURL URLWithString:sFeedURL] encoding:1 error:nil];
       NSLog(@"%@", sActualFeed);
} 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜