Html 无法使用stringByEvaluatingJavaScriptFromString对象-c

Html 无法使用stringByEvaluatingJavaScriptFromString对象-c,html,objective-c,extract,stringbyevaluatingjavascr,Html,Objective C,Extract,Stringbyevaluatingjavascr,我的代码: [Web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:filePath]]]; NSString *html = [Web stringByEvaluatingJavaScriptFromString: @"document.getElementsByClassName('bottomwideborder')[1].innerHTML;"]; NSLog(@"%@", html); 不适

我的代码:

[Web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:filePath]]];
    NSString *html = [Web stringByEvaluatingJavaScriptFromString: @"document.getElementsByClassName('bottomwideborder')[1].innerHTML;"];
    NSLog(@"%@", html);
不适用于此html文件-(我尝试从html提取表)


请帮帮我

我假设您使用的是Cocoa Touch(iOS),对于Cocoa(Mac OS X),它有点不同
loadRequest启动异步客户端请求
您应该为实现
UIWebViewDelegate
协议的web视图分配一个委托,并将代码移动到
webViewDidFinishLoading
方法中:

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSString *html = [webView stringByEvaluatingJavaScriptFromString: @"document.body.getElementsByClassName('bottomwideborder')[1].innerHTML;"];
    NSLog(@"%@", html);
}