Reputation: 4755
I'm currently pulling in user data from a site where the user must authenticate before reaching the page where the data exists. I've managed to do so by using a combination of javascript injection (transfers uitextfield strings to the web form), NSURL (pulls in content) and Hpple (for parsing through the html). However I feel like there must be a better way or a better library out there.
I'm currently using NSUserDefault Bool Keys to check if the user is authenticated or not, but it's a little jittery.
I've heard of AFNetworking but I never was able to quite figure out what I needed. Right now I'm basically loading a hidden webview with the login page, injecting the uitextfield data into the page, authenticating, and then displaying a new view with the scraped data. Could anyone recommend an example or tutorial regarding AFNetworking and authentication? Keep in mind that this site has no api or for that matter api keys etc. My content is also plain html (most tutorials talk about json). :\
Thank you so much!
Upvotes: 1
Views: 229
Reputation: 661
If I may, I'm the author of WebHere, an Objective-C framework for doing exactly what you're expecting, scraping HTML pages. It's mostly based on CSS selectors and you can find an example in the repository.
You would start by modeling the data you're interested in in the form of a class holding your model values, then let the framework do the request and parse the HTML. This is based upon AFNetworking by the way.
As for the authentication part, you would typically create a Form object with the authentication data and tell the framework what page "model" you would expect in return.
For other solutions, I know Osmosis which is written in Swift that also does the job of parsing HTML pages.
Upvotes: 1