0
我想解析一個有很多表格的HTML頁面。我搜索瞭如何使用Objective C解析HTML,並發現了hpple。我會找一個教程,導致我:如何解析HTML中的表格?
http://www.raywenderlich.com/14172/how-to-parse-html-on-ios
有了這個教程中,我試圖解析一些論壇新聞裏面有很多表,從該網站(希伯來文):news forum
我試圖解析新聞標題,但我不知道在我的代碼中寫什麼。每次我嘗試到達我得到的路徑時,「節點都是零」。
我的最新嘗試的代碼是:
NSURL *contributorsUrl = [NSURL URLWithString:@"http://rotter.net/cgi-bin/listforum.pl"];
NSData *contributorsHtmlData = [NSData dataWithContentsOfURL:contributorsUrl];
// 2
TFHpple *contributorsParser = [TFHpple hppleWithHTMLData:contributorsHtmlData];
// 3
NSString *contributorsXpathQueryString = @"//body/div/center/center/table[@cellspacing=0]/tbody/tr/td/table[@cellspacing=1]/tbody/tr[@bgcolor='#FDFDFD']/td[@align='right']/font[@class='text15bn']/font[@face='Arial']/a/b";
NSArray *contributorsNodes = [contributorsParser searchWithXPathQuery:contributorsXpathQueryString];
// 4
NSMutableArray *newContributors = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in contributorsNodes) {
// 5
Contributor *contributor = [[Contributor alloc] init];
[newContributors addObject:contributor];
// 6
有人能指導我要得到冠軍?