Objective c 解析器返回奇怪的脚本

Objective c 解析器返回奇怪的脚本,objective-c,ios,parsing,Objective C,Ios,Parsing,我在试着分析。NSLog给了我一个奇怪的结果: Aktualne kursy walut - Alior Bank if( window.opera ) { if ('fast' == history.navigationMode) { history.navigationMode = 'automatic'; location.reload(); } else { history.navigationMode = 'fast';

我在试着分析。NSLog给了我一个奇怪的结果:

Aktualne kursy walut - Alior Bank
if( window.opera ) {
    if ('fast' == history.navigationMode) {
        history.navigationMode = 'automatic';
        location.reload();
    } else {
        history.navigationMode = 'fast';
    }
}
可能是什么?解析此页面的正确方法在哪里?我的工作代码:

NSError * error = nil;
    HTMLParser * parser = [[HTMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.aliorbank.pl/pl/o_banku/kursy_walut/kursy_walut_aktualne/main"] error:&error];    
    if (error) {
        NSLog(@"Error: %@", error);
        parser = nil;
        return 0;
    }
    HTMLNode * bodyNode = [parser doc];

    NSLog(@"parser = %@", [bodyNode allContents]);
编辑 我想用汇率值解析这个表。但是当我试图搜索一个类为“currencyTable”的表时,我什么也得不到。我的代码:

HTMLNode * bodyNode = [parser doc];
HTMLNode *myNode = [bodyNode findChildOfClass:@"currencyTable"];
NSLog(@"table = %@", [myNode allContents]);
NSLog给了我“table=”。如何获取此表?

我查看了源代码

view-source:http://www.aliorbank.pl/pl/o_banku/kursy_walut/kursy_walut_aktualne/main
(以镀铬方式打开)

它似乎只返回标记之间的信息

例如,标题标记为:

<title>Aktualne kursy walut - Alior Bank</title>
下一个在标记之间包含任何文本的html源代码如下:

<script>
if( window.opera ) {
    if ('fast' == history.navigationMode) {
        history.navigationMode = 'automatic';
        location.reload();
    } else {
        history.navigationMode = 'fast';
    }
}
</script>
我不认为这是一个“奇怪”的结果。总的来说,我想我不得不问,你期待什么?

编辑 看过文档中的示例后,我会这样尝试:

NSError * error = nil;
HTMLParser * parser = [[HTMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.aliorbank.pl/pl/o_banku/kursy_walut/kursy_walut_aktualne/main"] error:&error];    
if (error) {
    NSLog(@"Error: %@", error);
    parser = nil;
    return 0;
}
HTMLNode * bodyNode = [parser body];
NSArray *tableNodes = [bodyNode findChildTags:@"input"];

HTMLNode *tableToParse = nil;
for (HTMLNode *tableNode in tableNodes) 
{
    if ([[tableNode getAttributeNamed:@"class"] isEqualToString:@"currencyTable"]) 
    {
         tableToParse = tableNode;
         break;
    }
}

//Proceed to parse this table node in a similar way.
NSLog(@"Table to parse : %@", [tableToParse rawContents]);

请注意,我没有测试此代码,这只是从文档中编写的。

响应有什么“奇怪”之处?您能否发布一个指向您正在使用的库的链接,以便我查看它的文档。
[inputNode GetAttributeName:@“class”]
我在这里有一个错误。什么是
inputNode
可能是
tableNode
?应该是tableNode。幸运的是,代码不起作用:(
要分析的表:(null)
尝试打印出每个中间点:
NSLog(@“%@,[bodyNode rawContents]);NSLog(@“%@”,tableNodes);
等以查看问题的起因
 if( window.opera ) {
    if ('fast' == history.navigationMode) {
        history.navigationMode = 'automatic';
        location.reload();
    } else {
        history.navigationMode = 'fast';
    }
}
NSError * error = nil;
HTMLParser * parser = [[HTMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.aliorbank.pl/pl/o_banku/kursy_walut/kursy_walut_aktualne/main"] error:&error];    
if (error) {
    NSLog(@"Error: %@", error);
    parser = nil;
    return 0;
}
HTMLNode * bodyNode = [parser body];
NSArray *tableNodes = [bodyNode findChildTags:@"input"];

HTMLNode *tableToParse = nil;
for (HTMLNode *tableNode in tableNodes) 
{
    if ([[tableNode getAttributeNamed:@"class"] isEqualToString:@"currencyTable"]) 
    {
         tableToParse = tableNode;
         break;
    }
}

//Proceed to parse this table node in a similar way.
NSLog(@"Table to parse : %@", [tableToParse rawContents]);