
Can I add a Wikipedia search box to my Web site or blog?I found instructions for adding a cool Google search box to an html/xhtml site, here on askdavetaylor. I want to add a similar Wikipedia search box to my website. Any advice on where I can get code to do this? There's always a way to do this sort of thing and Wikipedia is a splendid example of exactly how to reverse engineer a search box and pour it into a rudimentary form. Let's dig into it and you'll see what I mean!! Go to the site's home page and you'll see that they have a very simple search box with no fancy bells and whistles: ![]() The only fancy part is the language selector, but that's easily duplicated if you want to be truly polyglot on your site. If not, the default is English so that might work just perfect for your needs. One way to do this is to just copy and paste from their page source, which looks like this: ![]() I prefer doing things for myself, however, but this gives me all the information necessary: the name of the target CGI search utility and the names of the variables involved. Stripping it to its most basic, pre-selecting English, and carrying across the hidden variable from the source, here's how a crude Wikipedia search might look: <form action="http://www.wikipedia.org/search-redirect.php" method="get">
<input type="text" name="search" size="20" /> <input type="hidden" name="language" value="en" /> <input type="submit" name="go" value=" > " /> <input type="hidden" name="go" value="Go" /> </form> Turns out we can clean this up just a little bit and make it more friendly too: <form action="http://www.wikipedia.org/search-redirect.php" method="get">
Search Wikipedia: <input type="hidden" name="language" value="en" /> <input type="text" name="search" size="20" /> <input type="submit" name="go" value=" Go! " /> </form> That's all there is to it. Here, try it: Simple enough, eh? Hope that helps you tap into the splendid resource that is Wikipedia.
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon
Categorized:
CGI Scripts and Web Site Programming
(Article 6981)
Tagged: html, search engines, web site customization, wikipedia Previous: I need help from an expert on how to focus my blog? Next: Can I earn commissions referring people to Google AdWords? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. Dear Dave, Thanks and more power to you Day Posted by: Day Magtoto at July 24, 2007 6:25 PMwhere can i get the source code for wikipedia but in php4 format? I tried hard to find it but to no luck please help!!! Posted by: wayne at March 13, 2008 6:29 AMWayne, I don't know if it's in PHP4 or not, but Wikipedia's back end is called "Media Wiki" and you can Google that to find out a lot more information about the application. It is free and you can download it. Good luck! Posted by: Dave Taylor at March 13, 2008 11:03 AMCan the Wikipedia workaround above also be done for mobile websites? Posted by: B.B. at July 15, 2008 3:59 PMInstead of changing languages, is it possible to have a list of search engines (Google, Wikipedia, Google Images, IMDB, etc. etc.) to choose from; like in the firefox toolbar? Posted by: Stephanie Mott at September 28, 2008 11:50 AMWHERE CAN I FIND A TRAVEL QUESTION ANSWERING SEARCH ENGINE TO PUT ON MY WEBSITE Posted by: TGoGuide at February 10, 2009 7:42 AMHi dave, I want to know how can i add MySpaces people search box in my website. I have tried all the tricks u have mentioned in here, but its 2 hard for me am not just able to get it. I kindly ask for your help Thanks & Best Regards I read your wicipedia search box code. But how do you add a searchbox for wicipedia for asp.net webpages Posted by: MIke at September 18, 2009 3:49 PMI tried inputing the html you give above, the short version and the long, from here and from wikipedia itself, into the code for the DPC myspace page, hoping to provide yet another direct resource for data research, but the msplinks Base64 encoding system appears to be erasing the beginning of 'www' from the original wikipedia url address given in the form action above. It then of course does not work because it cannot find the server as the url is wrong. Do you have any clue as to how to overcome this? I know that myspace security, the msplinks system, does allow access to the main wikipedia address, whereas they have blacklisted google's blogger accounts from be linked within myspace, as they have done so to many other web domains. but perhaps you know of some way to protect the php wikipedia address given above so that the encoding system of myspace does not erase the original 'www' from the url? Any help you can offer would be much appreciated... ps. I really enjoy the short version of the wiki-search engine you provide, it is very nice looking on the DPC myspace page. so something link that would be nice. aloha, I have a lot to say, but ...
I do have a comment, now that you mention it!
|
![]()
Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Industry News and Trade Shows Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Book Links
|