WikiPath
What a neat idea: Ben Gottlieb’s WikiPath is a screensaver that displays pages from a random path through Wikipedia. You might think that it would take some work to find the URLs that a page links to, but -[WebView stringByEvaluatingJavaScriptFromString:]
makes short work of that.
5 Comments RSS · Twitter
I thought his use of javascript to get the links was quite clever. I used a much more tedious traversal of the DOM with DOMNode * in my ironcoder entry, WikiWalker (which was a similar idea, but not as well done -- although, I did figure out why mine was crashing so much, and plan on fixing it). I found the example of the DOMNode-walking on cocoadev.com, but only in the google cache (or rolling the page back to its original version).
Congrats again to Ben.
Wouldn't it be about as easy and less overhead to use XPATH? Something like ".//a" (it's been a while, so please correct me) should catch all of the links, no?
While xpath would be a lot easier, unfortunately I don't think WebKit has very good xpath support, if any.
WebKit doesn't give you the chance to perform an xpath on the DOM. He could have loaded the page seperately into NSXMLDocument and then used xpath but that's a) more work and b) wouldn't work so well on dynamic pages where content is created by JS.
Ben's solution was very slick and one of the reasons why I chose him as the winner.