Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

aatif

macrumors newbie
Original poster
May 26, 2008
10
0
hello,

Is there any way to get the source code of the webpage that is being displayed by the webview? Assume that I've provided the URL of this page.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
hello,

Is there any way to get the source code of the webpage that is being displayed by the webview? Assume that I've provided the URL of this page.

Yes, it's all in the documentation. Also it's very bad form to tag a question onto someone else's thread. Instead of hijacking their thread start your own.

The following will get the source code as part of a web frame load delegate:

Code:
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
	if (frame == [sender mainFrame] ||
		[frame parentFrame]==nil)
	{
		source = [[[[[webView mainFrame] dataSource] representation] documentSource] retain];
	}
}

Note that I only want the source from the main frame of the webview and check that this is the case.
 

aatif

macrumors newbie
Original poster
May 26, 2008
10
0
Thanx for ur help and guidance, however I got the solution as;

Code:
NSString *source = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"www.website.com"]];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.