I'm trying to build an iOS app like Pocket or Instapaper for practice. So, I need to fetch data from a url and strip the HTML of of it. I created the code below to do this.
NSURL *url = [NSURL URLWithString:self.link];
NSString *webData= [NSString stringWithContentsOfURL:url];
NSLog(@"webData is: %@", webData);
NSString *finalhtmlstring = [NSString stringWithFormat:@"%@", webData];
finalhtmlstring = [finalhtmlstring stringByConvertingHTMLToPlainText];
NSLog(@"FinalHTMLString is: %@", finalhtmlstring);
How would I fetch the body of the page? I can't get the NSString
between @"<body>"
and @"</body>"
, because some websites add attributes to the <body>
tag.