[英]extract table from index.html objective-c
问题如下:我正在尝试使用“ stringByEvaluatingJavaScriptFromString”从html获取表。 该表本身在NSLog中被拉出,但她不想出现在UIWebView中。 这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.html"];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:filePath]]];
}
- (void)webViewDidFinishLoad:(UIWebView*)webView1
{
NSLog(@"webViewDidFinishLoad");
html = [webView stringByEvaluatingJavaScriptFromString: @"document.body.getElementsByClassName('bottomwideborder')[1].innerHTML;"];
html1 = [NSString stringWithFormat:@"<html><body>%@</body></html>", html];
[webView loadHTMLString:html1 baseURL:[NSURL URLWithString:filePath]]; //Here page does not refresh
NSLog(@"%@", html1); //It's all displayed
[webView stopLoading];
}
我认为应该以某种方式更新此页面,但我不知道如何((
请帮助!
这可能是一个简单的变量错误命名错误。
我懂了:
- (void)webViewDidFinishLoad:(UIWebView*)webView1
而您将该功能中的所有内容都称为“ webView
”(不包含“ 1
”)。
另外,请确保您的“ webView
”不是NULL,并且正是您所期望的,因为您正尝试使用(显然正确解析的)“ html1
”代码加载它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.