1

我正在尝试获取 HTML 的标题标签,并正在使用 Hpple 来解析 HTML。出于某种原因,当我使用此代码时,我得到了 null

    NSURL *Url = self.webview.request.URL;
NSData *HtmlData = [NSData dataWithContentsOfURL:Url];
TFHpple *Parser = [TFHpple hppleWithHTMLData:HtmlData];
NSString *XpathQueryString = @"//head/title";
NSArray *Nodes = [Parser searchWithXPathQuery:XpathQueryString];
self.textfield.text = [NSString stringWithFormat:@"%@|%@", [[[[Nodes objectAtIndex:0] objectForKey:@"nodeChildArray"] objectAtIndex:0] objectForKey:@"nodeContent"], [Url absoluteString]];

[Nodes objectAtIndex:0]当我记录我得到的数组时

{
 nodeChildArray =     (
            {
        nodeContent = Google;
        nodeName = text;
    }
);
nodeName = title;
}
4

0 回答 0