IPhone: how to download a complete website?

What approach do you recommend for me to download a website (one HTML website with all images included) on iPhone?

The question is how to scan all these tiny bits (Javascripts, images, CSS) and save them locally. This is not about a specific implementation (I know how to use NSURLRequest, etc. I am looking for a traversal / spider approach).

Prison breaks will not work, as they are for the official app (App Store).

Hi,

Stephen

+3
source share
5 answers

Loading? Or get the HTML source of the site and display it using UIWebView?

If the latter, you can simply do this:

NSString *data = [[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://apple.com"] encoding:NSUTF8StringEncoding error:NULL];

// Load UIWebView with data
[webView loadHTMLString:data baseURL:[NSURL URLWithString:@"http://apple.com"]];

EDIT: , , regex iPhone .

: RegexKitLite Regex, , , <link rel="%" href="*"> src="*". , * .

:

URL- regex, URL- :

NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString pathToCurrentSite = [rootPath stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@/", fullUrlToPage]];
for (urlString in urlStrings) {
    NSData *stringData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
    [fileManager createFileAtPath:[pathToCurrentSite stringByAppendingPathComponent:urlString] contents:stringData attributes:nil];
}
NSString *data;
NSData *pageData = [data dataUsingEncoding:NSASCIIStringEncoding];
[fileManager createFileAtPath:[pathToCurrentSite stringByAppendingPathComponent:@"index"] contents:pageData attributes:nil];
[fileManager release];
+3

? , , , .

0

- , ( .)

, , .

-1

Source: https://habr.com/ru/post/1750738/


All Articles