Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

How can I create predefined Amazon search links?

I read your note about how to add an Amazon.com search box to your site and it's very cool, but what I want to know is: What if I want the search to only search a certain keyword, Example "Honda Parts"?


Dave's Answer:

Of all the major sites that I visit with frequency, there are non with a more Byzantine URL structure and organization than Amazon.com. I don't know what kind of back-end infrastructure decision they made years ago, but the whole "obidos" and session number thing really makes it a huge pain to work with the site, and forget about being able to email someone a URL so they can see a product for sale: their URLs are famously bizarre.

But! Don't panic!

When it comes to their search system, buried in all the junk, there is a parameter that contains the actual search string, so when I go to Amazon.com and simply search for "honda parts" from the home page, the resultant page has the following URL:

http://www.amazon.com/s/ref=nb_ss_gw/102-1882688-6100927?
initialSearch=1&url=search-alias%3Daps&field-keywords=honda+parts&Go.x=0&Go.y=0&Go=Go

Now it's just a matter of slicing until it fails: what parameters can we axe from this ghastly URL until we get just what we want?

The way I do this is to actually edit the URL within the Address box of my browser (Apple's Safari) and reload the page each time until it just doesn't bring up what I seek.

Do that and you'll quickly find that all the "Go" fields can be safely chopped off. Can we delete the url=search-alias%3Daps value?

Amazon.com Search Hack: No Results in Category...

Clearly not. We've ended up with a search that has no category specified, but the Amazon backend can't extrapolate a full-site search. Bummer.

How about the core URL? Can we tweak that a bit, losing the nb_ss_gw and/or the 102-1882688 jazz?

Surprisingly, yes, you can get rid of the numeric session ID value without breaking the search, something that's a bit confusing if you're used to all parameters being name=value pairs after the "?" symbol. You can even get rid of the ref= part of the URL, believe it or not. Lots of superfluous information in this search URL, as is obvious.

Heck, you can even get rid of the "first-search" value, leaving us with a much less scary URL:

http://www.amazon.com/s?url=search-alias%3Daps&field-keywords=honda+parts

Doesn't even need a line break. Better, you can now see how to add it to your site and how to use it as the wrapper for a button, say:

<a href="http://www.amazon.com/s?url=search-alias%3Daps&field-keywords=honda+parts"><img
src="amazon-search-honda.jpg" alt="Search for Honda parts at Amazon" /></a>

or just as a hypertext link unto itself:

<a href="http://www.amazon.com/s?url=search-alias%3Daps&field-keywords=honda+parts">Check Amazon.com for Honda parts</a>

Hope that helps you work with the Amazon search engine!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Great post, very helpful. Is it possible to add in an Amazon Associates ID so I can get credit for links I send their way?

®

Posted by: Richard Holt at March 6, 2008 2:53 PM

Great article...
However, I want to know the methods to include the referral link (tag=xxxxxx-20) inside the Amazon search codes.

Posted by: yosax at April 19, 2008 3:27 PM

I have a lot to say, but ...
Starbucks coffee cup I have a lot to say, and questions of my own for that matter, but most of all I'd like to say thank you for all your efforts on this Web site by buying you a chai!

I do have a comment, now that you mention it!









Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.









Uniblue: Free Virus Scan

Search
Find just the answers you seek from among our 2000+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Join the List!
Join my author info mailing list, where you'll learn about my upcoming books, speaking gigs, and more!


Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.