Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:52:43+00:00 2026-06-06T14:52:43+00:00

I want to save webpage in document directory with the images,css and javascripts etc..

  • 0

I want to save webpage in document directory with the images,css and javascripts etc..

I have done below code : But it only generates the html file..

NSURL *url = [NSURL URLWithString:@"http://www.apple.com"];
NSData *urlData = [NSData dataWithContentsOfURL:url];
[urlData writeToFile:filePath atomically:YES];

Any idea or suggestion is most welcome.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:52:44+00:00Added an answer on June 6, 2026 at 2:52 pm

    The ASIHTTPRequest project has a class called ASIWebPageRequest which is designed to do exactly what you want. If you’re okay with adding an additional dependency to your project then I think it’s a good solution for you: ASIWebPageRequest.

    On the page I liked above there are some good examples of how to use it but I’ll include one of them here for completeness:

    - (IBAction)loadURL:(NSURL *)url
    {
       // Assume request is a property of our controller
       // First, we'll cancel any in-progress page load
       [[self request] setDelegate:nil];
       [[self request] cancel];
    
       [self setRequest:[ASIWebPageRequest requestWithURL:url]];
       [[self request] setDelegate:self];
       [[self request] setDidFailSelector:@selector(webPageFetchFailed:)];
       [[self request] setDidFinishSelector:@selector(webPageFetchSucceeded:)];
    
       // Tell the request to embed external resources directly in the page
       [[self request] setUrlReplacementMode:ASIReplaceExternalResourcesWithData];
    
       // It is strongly recommended you use a download cache with ASIWebPageRequest
       // When using a cache, external resources are automatically stored in the cache
       // and can be pulled from the cache on subsequent page loads
       [[self request] setDownloadCache:[ASIDownloadCache sharedCache]];
    
       // Ask the download cache for a place to store the cached data
       // This is the most efficient way for an ASIWebPageRequest to store a web page
       [[self request] setDownloadDestinationPath:
          [[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:[self request]]];
    
       [[self request] startAsynchronous];
    }
    
    - (void)webPageFetchFailed:(ASIHTTPRequest *)theRequest
    {
       // Obviously you should handle the error properly...
       NSLog(@"%@",[theRequest error]);
    }
    
    - (void)webPageFetchSucceeded:(ASIHTTPRequest *)theRequest
    {
       NSString *response = [NSString stringWithContentsOfFile:
          [theRequest downloadDestinationPath] encoding:[theRequest responseEncoding] error:nil];
       // Note we're setting the baseURL to the url of the page we downloaded. This is important!
       [webView loadHTMLString:response baseURL:[request url]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With my code below, I have been able to save a cookie, but as
I have a WebView that is loading a webpage. I want to save all
what I want: Download a webpage from a server > Save content in a
I want to save and load my xml data using XmlReader. But I don't
I want to save a remote img-file to my server, but I don't know
I have a NSString that contains the html code of a webpage. Now, how
If I find a webpage I want to tinker with and I save the
I have to receive voice from my user's microphone into my webpage and save
I have a webpage with many links on it. I want to add a
I have a function in the code behind of an ASP.NET webpage that creates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.