discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading (opening) a website with GNUstep


From: Richard Frith-Macdonald
Subject: Re: Loading (opening) a website with GNUstep
Date: Sat, 11 May 2002 15:11:15 +0100

On Saturday, May 11, 2002, at 01:09 PM, Andreas Hoeschler wrote:

Hi,

I need to load (get the html code) of an url (e.g. http://www.mydomain.de/file.html). The html code of this page contains some information I need to extract. The first step is to get the html. How can I do this in GNUstep?

        NSString *htmlCode = ...        // input = URL; output = HTML code

Use the -resourceDataUsingCache: method of NSURL to get the data,
then use the -initWithDate:encoding: method of NSString to put it in a string.


eg.

NSURL *url = [[NSURL alloc] initWithString: @"http://www.mydomain.de/file.html";];
  NSData *data = [url resourceDataUsingCache: NO];
NSString *htmlCode = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];


Of course, there are much more sophisticated things you can do about error checking etc, but
that's about the simplest code.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]