|
|
How can I add an Amazon search box to my web page?You have shown how to add eBay, Google, and Technorati searches to your own web page. Is it possible to add an Amazon search to your page, and how would you do it? Of course it's possible! Everything is possible on the Web. :-) My first step is to go to Amazon.com and do a search, just to see the resultant URL. In this case, a search for Harry Potter reveals this scary URL: http://www.amazon.com/s/ref=nb_ss_gw/102-1882688-6100927?initialSearch=1&url=search-alias%3Daps&
field-keywords=harry+potter&Go.x=6&Go.y=15&Go=Go
Way more than I ever want to explore, but I can't help be curious what happens if I clean up everything except the actual search pattern, producing the following shorter URL: http://www.amazon.com/s/ref=nb_ss_gw/102-1882688-6100927?i
field-keywords=harry+potter
Ulp. Cut out too much and it doesn't work. Instead, let's work on getting rid of that ugly ref value. This URL does work: http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=harry+potter&Go.x=0&Go.y=0
a tiny bit more experimentation and we learn that a slightly shorter URL will work too: http://www.amazon.com/s/?url=search-alias%3Daps&field-keywords=harry+potter&Go=Go
Now we can reverse engineer the URL and turn it into a form. Everything before the "?" is the action of the form, and everything after is in name=value form, with those pairs separated by an "&" symbol. Tiny additional nuance: the "%3D" in the URL is an encoded "=" symbol, so we'll want to change that back as part of the code writing process. This means that the following should work: <form method="get" action="http://www.amazon.com/s/">
<input type="hidden" name="url" value="search-alias=aps" /> Search Amazon: <input type="text" name="field-keywords" /> <input type="submit" name="Go" value="Go" /> </form> Sure enough, it does. Try it here:
I admit, it's not the prettiest form we could create, but functionality-wise, I hope you can see how as with the other search boxes I've duplicated here, this is more a detective job than an HTML coding job. Tip: Want to have the search results open in a new window? Add the attribute target="new" to the FORM line.
More Useful HTML, JavaScript and Web Site Programming Articles:
✔ How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔ Can I embed a Facebook search box on my blog site?I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔ Can I use CSS for drop shadows on my blog?I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔ How can I embed interactive photo panoramas on my site/blog?I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔ How can I create a Twitter search URL shortcut?I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help
right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
Categorized:
HTML, JavaScript and Web Site Programming
(Article 7493,
Written by Dave Taylor)
Tagged: amazon search, html Previous: How do I protect my unpublished book while seeking a publisher? Next: Parallels on Mac: Connect USB Devices and Right Click? Reader Comments To Date: 3Bryan said, on September 28, 2007 9:39 AM:
What if I want the search to only search a certain keyword, Example "Honda Parts" ? rugamba jean paul said, on June 1, 2010 11:50 PM:
how can I creat a database in asp and connect it to html;please for any response send it for me at rugamba30@yahoo.fr
I do have a comment, now that you mention it!Check This Out Too... |
Recent Entries
Look for Answers
Recommended
All Our Categories
Apple iPad Help
Articles and Reviews Auctions and Online Shopping Blogs and Blogging Building Web Site Traffic Business and Management Computer and Internet Basics d) None of the Above Facebook Help Google Gmail Help Google Plus Help HTML, JavaScript and Web Site Programming Industry News and Trade Shows iPhone and Cell Phone Help iPod, Sony PSP and MP3 Player Help Kindle Fire Help Mac OS X Help Pay Per Click (PPC) Advertising Pinterest Help Search Engine Optimization (SEO) Shell Script Programming Tech Support Video Help The Writing Business Twitter, LinkedIn and Social Network Help Unix and Linux Help Video Game Tips and Help Windows PC Help Find Me on Google+ ADT on G+ |
Thank you for this tutorial, I have made a You Tube and a few other search boxes for my site because of it. some searches are quite difficult but it is a fun challange.