Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Yahllil

macrumors newbie
Original poster
Sep 9, 2015
4
0
I try to parse all the content of a specific column in a website into an NSMutableArray (at the end, I want to insert it into an Parse database).

Can anyone tell me how can I do that?
The URL is:
http://www1.shufersal.co.il/supersol_he/branches/search/brancheslocation.html

The XPath is: //*[@id="MainBody"]/table/tbody/tr[2]/td/table/tbody/tr/td[3]/table/tbody/tr[4]/td/table/tbody/tr[5]/td/table/tbody/tr[2]/td[8]
(I need the section ״כתובת״, sorry for the languege :) ).

My implementation:
Code:
    NSURL *tutorialUrl=[NSURL URLWithString:@"http://www1.shufersal.co.il/supersol_he/branches/search/brancheslocation.html"];
    NSData *tutorialsHtmlData=[NSData dataWithContentsOfURL:tutorialUrl];
  
    TFHpple *tutorialParser=[TFHpple hppleWithHTMLData:tutorialsHtmlData];
  
    NSString *tutorialXpathQueryString=@"//*[@id=""MainBody""]/table/tbody/tr[2]/td/table/tbody/tr/td[3]/table/tbody/tr[4]/td/table/tbody/tr[5]/td/table/tbody/tr[2]/td[8]";
    NSArray *tutorialsNodes=[tutorialParser searchWithXPathQuery:tutorialXpathQueryString];
  
    NSMutableArray *newTutorials=[[NSMutableArray alloc] initWithCapacity:0];
    for (TFHppleElement *element in tutorialsNodes) {
        Tutorial *tutorial=[[Tutorial alloc] init];
        [newTutorials addObject:tutorial];
        tutorial.title=[[element firstChild] content];
        tutorial.url=[element objectForKey:@"td"];
    }
    _objects=newTutorials;
    [self.tableView reloadData];

Can anyone help me? Thanks!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.