stringByEvaluatingJavaScriptFromString not return

2019-09-15 06:07发布

问题:

[wvPage stringByEvaluatingJavaScriptFromString:
    @"function getDes(){var attrs = document.getElementsByClassName('description')[0];"
        "attrs = attrs.getElementsByClassName('table')[0]"
        "attrs = attrs.getElementsByTagName('li);"
        "var result='',i;"
        "for(i=0; i<attrs.length; i++)"
        "{"
        "  result += attrs[i].getElementsByTagName('span')[0].innerHTML + ':' + attrs[i].getElementsByTagName('p')[1].innerHTML"
        "  if(i+1!=attrs.length)"
        "     result += '|'"
        "}"
    "return result;}"];

NSString* attribute_list = [wvPage stringByEvaluatingJavaScriptFromString:@"getDes()"];

I use those line to get one string but nothing returned. What's wrong??

The target HTML is Here: http://d.pr/n/WT5a