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:
Can anyone help me? Thanks!
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!