Reputation: 9157
I was told to retrieve data from this website on traffic in Sao Paolo, Brazil:
I have to retrieve information which is displayed all over the place, including other links/parts of the site. Im not so sure how. I have to parse HTML and have found a tutorial which does so, but it does not teach me how to parse this website, or any other in particular.
If you go to that website you will see four squares saying North, South, East West and the KM of their traffic or something, I have to gather that data and information. But how !? And also, I have to get the map image of traffic from this site:
http://www.cetsp.com.br/transito-agora/leste/mapa-de-fluidez.aspx
Again, but how? I have the HTML parsing classes hpple. Here is the code I know so far:
NSURL *tutorialsUrl = [NSURL URLWithString:@"http://www.cetsp.com.br"];
NSData *tutorialsHtmlData = [NSData dataWithContentsOfURL:tutorialsUrl];
TFHpple *tutorialsParser = [TFHpple hppleWithHTMLData:tutorialsHtmlData];
So I'm really boggled on how to even start on this. If anyone could help me, that would be great!
Upvotes: 1
Views: 168
Reputation: 6985
For every piece of data you want, you're going to need to write some code to retrieve that data from the document tree in the HTML.
The first step is to open the site in Safari/Chrome's web inspector and get a feel for where in the tree the data you want is.
Next, you'll want to write code to navigate to that point in the document tree and pull that data out. Whenever I've had to do something like this I've been spoiled by being able to use a language like python that has a lot of modules available to accomplish this. I'm not super familiar with what Cocoa has available in this area, but have a look at:
http://www.raywenderlich.com/14172/how-to-parse-html-on-ios
Ray has provided a pretty good worked example that should get you up and running. Perhaps you've already seen this article, in which case you're well on your way. You just need to find your paths thru the document to the elements you need.
Upvotes: 3