Parse HTML in Objective-C -


hello!

this iphone

this trying achieve:

this website expands urls bit.ly/miniscurl creator got api says have go website:

http://expandurl.appspot.com/expand?url=yoururl

so when put:

http://expandurl.appspot.com/expand?url=bit.ly/miniscurl

it returns new website information:

{     "status": "ok",      "end_url": "http:\/\/miniscurl.dafk.net",      "redirects": 1,      "urls": ["http:\/\/bit.ly\/miniscurl", "http:\/\/miniscurl.dafk.net"],      "start_url": "http:\/\/bit.ly\/miniscurl" } 

and great! how information nsstring , search through different tags. @ last got this:

nsstring *status = ok; nsstring *end_url = http:\/\/miniscurl.dafk.net"; etc... 

also nsarray containing redirects (if there more one) have been great!

conclusion:

i need:

  • a fast , easy way html source website.
  • a fast , easy way search through nsstring , cut in different pieces.

thank you!

best regards kristian

to data http-server, can use [nsdata datawithcontentsofurl:].

to parse data, in case seems json-data, can use simple json parser touchjson.

here example code wrote 1 of apps:

nsurl *url = [nsurl urlwithstring:@"http://server.com/data.json"]; nsdata *rawjsondata = [nsdata datawithcontentsofurl:url];  cjsondeserializer *parser = [cjsondeserializer new]; nserror *error; nsdictionary *jsondictionary = [parser deserializeasdictionary:rawjsondata                                                           error:&error];  [parser release]; 

hope helps!

also, looks new here. please mark answer helps clicking "√" on left, thanks!


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -