Hello,
I would like to save a webpage programmatically with Cocoa to the hard disk as a webarchive like Safari.
I've searched for any example programs from Apple yesterday, but I've only found a class reference at Apple Developers page for a webarchive class. I play a little bit with the webarchive class and unfortunately my solution don't give any ouput.
NSURL *url = [NSURL URLWithString:@"http://www.google.de"];
NSURLRequest *urlRequest = (NSMutableURLRequest*)[NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:30.0];
NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
WebArchive *wa = [[WebArchive alloc] initWithData:urlData];
NSData *waData = [wa data];
NSLog(@"%@", [[NSString alloc] initWithData:waData encoding:NSUTF8StringEncoding]);
I hope somebody could post a solution for my problem.
Thanks in advance
Michael