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. In fact, the process is identical for most all Web sites that you can search, like Google, but that’s a separate article.
For this piece, let’s dig into how Wikipedia works and you’ll see what I mean.
To start out, if you 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:
<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:
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.
I have tried this and i think the form action url is wrong. please reply thank you
Nope, just tested the one within the tutorial page itself and it worked just fine, Nicholas. Does the one on this page work for you?
Any body know me how can I included my webpage url in Wikipedia.
I tried to add it here : http://fav.me/d4if8hv but it didn’t work. could u help me plz ?
Please answser soon !
I wanted to have a FAQ button on the menu bar of my site, that took the user to a wikipedia page (with all the answers). I have the page here
http://en.wikipedia.org/wiki/Banking_in_Switzerland
Am I legally able to link to wiki without infringing copyright? Then surely just a case of creating a button with a url link behind?
Thanks
Dave,
instead of the text ‘Search Wikipedia’, how would we instead display the Wikipedia logo ? so it looks something like this …
(LOGO) search [ ]
Thanks in advance. And please forgive the noob question 🙂
Azman
Hi,
Thax,for this information.
I would like to know if i can add yahoo or gmail login page on my website.Plz reply
Thanks for providing this valuable information.
Nice post
Sajal, what’s the purpose of having a Yahoo or Google login box on your site? Sounds like a recipe for trouble. Not sure why? Go and search for “phishing” and you’ll instantly see the problem.
Hi,
Thax,for providing so muck valuable information.
U are ” Brilliant “.
I would like to know if i can add yahoo or gmail login page on my website.Plz reply
I 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,
Agent X of the DPC
I read your wicipedia search box code. But how do you add a searchbox for wicipedia for asp.net webpages
Hi dave,
i am from india and i am trying to build my own website. I found a lot of useful things in your articles about adding search boxes.
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
Abhijeet Deshpande
WHERE CAN I FIND A TRAVEL QUESTION ANSWERING SEARCH ENGINE TO PUT ON MY WEBSITE
Instead 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?
Can the Wikipedia workaround above also be done for mobile websites?
Wayne, 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!
where can i get the source code for wikipedia but in php4 format?
I tried hard to find it but to no luck
please help!!!
Dear Dave,
I am just starting with web design. Though I am a dentist here in this third world country the Philippines, I am doing this because life is hard here in this part of the world.
Actually, I have 2 questions:
1. How do you make a page where when your client scrolls down, the background does not move? Only the contents like texts and graphics move.
2. How do you make this form in your site where the answers to the text boxes are sent to your email?
3. If I would make a personal search box, how would I make the page where the list of search results will be placed?
Thanks and more power to you
Day