cocoa touch - iPhone: How to download a full website? -


Which approach do you recommend to download a website (an HTML site with all the included images) in the iPhone?

The question is how to crawl all these small bits (javascript, images, css) and save them locally. This is not about concrete implementation (I know how to use NSRRXST and accessories. I am looking for crawl / spider approach.)

The prison breaks will not work because it An official app store) app

Regards,

Stephen

downloading ? Or before you can get the HTML-source of the site and display it with the UIWebView

, you can do just that:

  NSString * Data = [[NSString alloc] initWithContentsOfURL: [NSURL URLWithString: @ "http://apple.com"] Encoding: NSUTF8StringEncoding Error: NULL]; // Load UIWebView with WebView [WebView Load HTML String: Data baseURL: [NSURL URLWithString: @ "http://apple.com"]];  EDIT:  EDIT:  For this approach, you might be best to use a Rijks-Library for iPhone so that you can parse through the string And find the necessary items.  

You can use it: For example, & lt; Link rel = "%" href = "*" & gt; and src = "*" . But you have to remember to store them and change the values ​​* with the new route.

Archiving files:

You will find Regex-methods from behind the URL, and you can write a file like this from the url:

  NSFileManager * fileManager = [[NSFileManager alloc] init]; NSString Route Path = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, Yes) objectAtIndex: 0]; NSString pathToCurrentSite = [Route Path Stringbacking Path Component: [NSString stringWithFormat: @ "/% @ /", fullUrlToPage]]; (UrlString in UrlStrings) {NSData * stringData = [NSData dataWithContentsOfURL: [NSURL URLWithString: urlString]]; [FileManager createFileAtPath: [pathToCurrentSite stringByAppendingPathComponent: urlString] Content: String data attributes: zero]; } NSString * data; NSDTA * Pagedata = [Data Data Device Encoding: NASCIITTN encoding]; [FileManager createFileAtPath: [pathToCurrentSite stringByAppendingPathComponent: @ "index"] content: pageadata property: zero]; [File manager release];  

Comments