Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Using Swift to create a web crawler

Hello everyone.

I would like to develop a webcrawler from zero. I want to use Swift for this as it is the language I am feeling most comfortable with. Is there any reason I should not use Swift? It has been described as a powerful language and I am liking it.

Also, coming to code, in a playground I wrote:

let snaiURL = NSURL(string:"http://www.snai.it/scommesse")
let snaiContent = NSData.dataWithContentsOfURL(snaiURL, options: nil, error: nil)

println(snaiContent)

This results into:

<3c21444f 43545950 45206874 6d6c2050 55424c49 4320222d 2f2f5733 432f2f44 54442058 48544d4c 20312e30 20547261 ........>

It is very long. I presume this is hex format, Is there a way to get JSON data from here?

Does someone know where I can read more about this?

Thanks

Vittorio

1 Answer

You need NSJSONSerialization, json data in the raw is pretty useless to us as way of data output as you can see lol. https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSJSONSerialization_Class/