0

I'm trying to cache the mobile Gmail webpage because UIWebView does not cache the content itself (mobile safari does, but not UIWebView).

I tried the methods listed here Reading HTML content from a UIWebView basically saving the html either directly from URLRequest or from UIWebView itself. When I try to put the html saved back into UIWebView it is not the same page!

This is the page that I want to save

alt text http://img39.imageshack.us/img39/5679/screenshot20090830at123.png

This is the page that the html saved will display

alt text http://img39.imageshack.us/img39/8734/screenshot20090830at122.png

Community
  • 1
  • 1
erotsppa
  • 14,248
  • 33
  • 123
  • 181

2 Answers2

1

If you're loading using loadData:MIMEType:textEncodingName:baseURL: make sure you're setting baseURL correctly - that way, the WebView will know where to look for relative stylesheets and so on.

Edit: For example, if I was saving this page, I'd set the base URL to Just can't seem to fetch the mobile Gmail html, what is wrong?.

Community
  • 1
  • 1
iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • Can I find the baseURL programatically from the UIWebView after the page is loaded? – erotsppa Aug 30 '09 at 19:41
  • It isn't something that can be programatically figured out as it depends on the configuration of the server. However, if you're at domain.com/some/path/page.html, domain.com is often the base URL. – iKenndac Aug 30 '09 at 21:29
0

That looks like the same page to me, but with different stylesheets attached. If you're just re-displaying identical HTML from your local server, the relative stylesheet paths in Google's HTML would no longer be correct. Also, any AJAX requests meant to run after the page loads would no longer work (both because the relative paths to the scripts would be wrong, and also because Cross-Site Scripting restrictions would prevent them from contacting Google).

Attempting to scrape content from an AJAX-enabled application is no small undertaking. You'd have to replicate a lot of GMail's functionality to truly reproduce the exact page Google presents.

VoteyDisciple
  • 37,319
  • 5
  • 97
  • 97