With this script, you can extract bits of data from any site based on MediaWiki (including Wikipedia). I’ve also made a more complex version of the code that allows you to grab certain categories and images using the same function with different parameters (but I need to clean it up before I post it).

It should be pretty much self explanatory, let me know if you need help figuring it out.

I have been using your technique for sometime, but lately it seems to have failed. The failure however may be do to the fact I am behind the great Firewall of China. Or it may be that like Google Wikipedia has changed an API, so my question is does this technique still work in the free world?