Re: Getting HTML
Re: Getting HTML
- Subject: Re: Getting HTML
- From: "John C. Randolph" <email@hidden>
- Date: Thu, 14 Jun 2001 09:07:16 -0700
On Wednesday, June 13, 2001, at 12:12 PM, email@hidden wrote:
Whats the easiest way to get the HTML from a given URL? The only
examples I have seen have been the OmniGroups, and they arent helping
me much...too complex. I just need to take the HTML and assign it to a
string, and then later on use the string. Any suggestions?
Just did this about two days ago:
- (IBAction)retrieveURL:(id)sender
{
NSURL *where =
[NSURL URLWithString:[[[sender stringValue] mutableCopy]
stringWithPrefix:@"
http://" suffix:@"/"]];
NSAttributedString
*content =
[[NSAttributedString alloc]
initWithHTML:[NSData dataWithContentsOfURL:where]
documentAttributes:nil];
[[ContentText textStorage] setAttributedString:content];
}
-stringWithPrefix:suffix: is defined in a MiscKit category, it simply
ensures that the string in question has the given prefix and suffix.
ContentText is an NSTextField.
Hope this helps,
-jcr
"The right to be heard does not include the right to be taken
seriously." - Hubert Humphrey