Accessing a website Page Source
Ah yes, this is an easy one. You just do a get on the web server and you're done.
int main3(int argc,const char* argv[])
{
int result = 0 ;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
if ( argc != 2 ) {
NSLog(@"syntax: httpget url") ;
result = -1 ;
} else {
NSString* sURL = [[NSString alloc]initWithCString:argv[1]];
NSURL* uURL = [NSURL URLWithString:sURL] ;
NSString* sPage = [[NSString alloc]initWithContentsOfURL:uURL] ;
NSLog(@"%@",sPage) ;
}
[pool drain];
return result ;
}
561 /Users/rmills/Projects/httpget/build/Debug> httpget http://clanmills.com/robin.shtml
2010-01-20 23:02:43.905 httpget[13413:903] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD>
.......... lots of stuff deleted .........
</body>
</html>
562 /Users/rmills/Projects/httpget/build/Debug>