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 236337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:20:13+00:00 2026-05-11T20:20:13+00:00

Is it possible to read the raw HTML content of a web page that

  • 0

Is it possible to read the raw HTML content of a web page that has been loaded into a UIWebView?

If not, is there another way to pull raw HTML content from a web page in the iPhone SDK (such as an equivalent of the .NET WebClient::openRead)?

  • 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-05-11T20:20:14+00:00Added an answer on May 11, 2026 at 8:20 pm

    The second question is actually easier to answer. Look at the stringWithContentsOfURL:encoding:error: method of NSString – it lets you pass in a URL as an instance of NSURL (which can easily be instantiated from NSString) and returns a string with the complete contents of the page at that URL. For example:

    NSString *googleString = @"http://www.google.com";
    NSURL *googleURL = [NSURL URLWithString:googleString];
    NSError *error;
    NSString *googlePage = [NSString stringWithContentsOfURL:googleURL 
                                                    encoding:NSASCIIStringEncoding
                                                       error:&error];
    

    After running this code, googlePage will contain the HTML for http://www.google.com, and error will contain any errors encountered in the fetch. (You should check the contents of error after the fetch.)

    Going the other way (from a UIWebView) is a bit trickier, but is basically the same concept. You’ll have to pull the request from the view, then do the fetch as before:

    NSURL *requestURL = [[yourWebView request] URL];
    NSError *error;
    NSString *page = [NSString stringWithContentsOfURL:requestURL 
                                              encoding:NSASCIIStringEncoding
                                                 error:&error];
    

    EDIT: Both these methods take a performance hit, however, since they do the request twice. You can get around this by grabbing the content from a currently-loaded UIWebView using its stringByEvaluatingJavascriptFromString: method, as such:

    NSString *html = [yourWebView stringByEvaluatingJavaScriptFromString: 
                                             @"document.body.innerHTML"];
    

    This will grab the current HTML contents of the view using the Document Object Model, parse the JavaScript, then give it to you as an NSString* of HTML.

    Another way is to do your request programmatically first, then load the UIWebView from what you requested. Let’s say you take the second example above, where you have NSString *page as the result of a call to stringWithContentsOfURL:encoding:error:. You can then push that string into the web view using loadHTMLString:baseURL:, assuming you also held on to the NSURL you requested:

    [yourWebView loadHTMLString:page baseURL:requestURL];
    

    I’m not sure, however, if this will run JavaScript found in the page you load (the method name, loadHTMLString, is somewhat ambiguous, and the docs don’t say much about it).

    For more info:

    • UIWebView class reference
    • NSString class reference
    • NSURL class reference
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to read the content of a file that has been selected
Are there any free-to-use libraries for .NET so that I can read Canon's raw
I know that it is possible read and write data from mongodb via hadoop.
I'm sure I read that it was possible to take an email in RFC
Is it possible to refer to an external file [not present in the res/raw
This question has been asked more than once before, but I have not found
Is possible to read from a txt file in loop like this? files names:
did it is possible to read the setting file permissions(Octal Notation/Symbolic Notation) using php
Is it possible to read a disk directly with .NET? By directly, I mean
Is it possible to read and write Word (2003 and 2007) files in Python

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.