Yes, my code was just an example, not a production-ready script. You will definitely have to modify it.
- If you type in a more than one word parsing phrase, it won't return anything.
example "new york" won't show anything.
then "new_york" will show you that you need to redirect and use proper capitalization.
ultimately, "New_York" will show you the proper display.
Modify the script to handle that
Read Mediawiki's API documentation and see how to handle redirects.
- I'd only like to show the first <p> from the a wikipedia listing. this will put less strain on my server as well as wikipedia's. and, yes, i've downloaded to wikipedia multiple times now, whenever a call out was made.
I think the API only returns the whole page. From that, you'd grab the first paragraph. I think returning the whole page would be less stressful on their servers as they'd cache the whole page (they wouldn't just cache the first paragraph) so it should be relatively quick to retrieve anyways.
A perfect example of what I'm trying to replicate can be seen at
They might be using the API, or might just use the Wikipedia dumps I talked about earlier. Perhaps ask them what approach they used?