开发者

download a web page with objective-c

How can i download the html content of a webpage giv开发者_如何学运维en an url? using objective c..


Use stringWithContentsOfURL:usedEncoding:error: from NSString

NSURL * url = ... some url
NSError * error;
NSStringEncoding * encoding;
NSString * htmlContent = [NSString stringWithContentsOfURL:url usedEncoding:&encoding error:&error];


Assuming it's on iPhone or Mac OS X, use the sample here:

http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

Linking CURL with Objective C might be possible, but why?


Depends on what you are trying to do. For a web view:

webView = [[UIWebview alloc] loadRequest:(NSURLRequest *)request];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜