
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"? 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? ![]() 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
Categorized:
CGI Scripts and Web Site Programming
(Article 7607)
Tagged: amazon.com, cgi programming, search engines Previous: Can I add a photo to my LinkedIn profile? Next: Dealing with a non-paying deadbeat buyer on eBay? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. 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 PMGreat article... 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 2000+ 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
Join the List!
Book Links
|