View Full Version : Special Search!

03-13-2004, 07:40 PM
Hey everyone. Here's a cool puzzle, I wonder if any of you can solve it, cuz I can't :-)

I'd love to create a VERY small website that exists for no other reason that to allow AMG All Music Guide (www.allmusic.com) searches via the Google Deskbar. So far, customized searches in the Google Deskbar only support URL searches. An example is a simple Google Deskbar search of imdb.com: http://www.imdb.com/find?tt=on;nm=on;mx=20;q={1} - where the contents of {} are replaced with the search term. It works perfectly. However, allmusic.com uses a dll search.

Now, the source code for allmusic.com front page show that the search is conducted in the following form:

<form action="/cg/amg.dll" method="POST" target="_top" name=d><input type="HIDDEN" name="P" value="amg">

...and with the following input box:

<input type="textfield" name="sql" size="25" maxlength="30">

Radio button also in the form determine if the search is for artist, album, style, etc., but I can worry about that later.

So, what I'm thinking is that perhaps I can set up my own site where a Google Deskbar customized search would send the user to, say:


...and when the page loads it will automatically use Javascript to put the term (in this case, "metallica") into a variable, and then use that variable as the text submitted to the "http://www.allmusic.com/cg/amg.dll" form, remotely.

Is this kind of thing even possible? I haven't used Javascript or HTML for a couple years now and I'm a little rusty.

If that's not possible, is there another way of pulling this off that you can think of?

Thanks SO MUCH for your time, everyone!

03-14-2004, 10:49 PM
You don't have to use a form if they allow you to use the get method. Since this works:

you should be able to use this URL and query string rather than the form with the post method. Just replace the value for sql with your search term.

You should note that in the allmusic form there are five possible values for opt1:

03-14-2004, 11:12 PM

Now, how did you figure out what the correct URL was????


03-14-2004, 11:21 PM
In their form they had action="/cg/amg.dll" which says to go to the root then the directory cg then the file amg.dll. The root is their web domain. As for getting the query string correct it is just each of the form elements named and values starting with a question mark and separated with ampersands.

Their is nothing magic about it, this is all very standard stuff.

03-15-2004, 12:12 AM
Ah, okay. Yes, I knew about the domain thing already but I wasn't aware of the "standard stuff." Is there perhaps a tutorial online somewhere that will explain what the "standard" URL and forum submission "stuff" is?

03-15-2004, 12:20 AM
The easiest way to see the query string that a given form will build is to change the method from "post" to "get" and to veiw the string in the address bar after it is submitted.

03-15-2004, 12:23 AM
Or perhaps it's this simple:

There are three seperately-named <input> items in the <form> (besides inputs of type "image"). One is named "p" and the value is "amg." One is named "sql" and this the value to be searched. The last is named "opt1" and the value is the TYPE of search happening.

All of this is derived from the source code. In determining a destination search URL, one must simply begin with the domain and search "object" (in this case: http://www.allmusic.com/cg/amg.dll), add a "?", and seperate each input object name from its value with a "=", and each input object name/value pairing with a "&".

Now, if you're saying this is all "standard" stuff, then these rules should apply to most search forms on a web page, and all one has to do is find in the source code the search "object/page", domain, and seperately-named input items. Am I right?

One final question: what is the significance of an <input type=image> in this scenario of determining a search URL?

Okay, hopefully I've figured it out so you don't have to keep spelling it for me.

Thanks again for your time!

03-15-2004, 12:23 AM
Heh, looks like we were posting replies at the same time. Okay, thanks, I'll try the "GET" method to reverse-engineer query URLs.


03-15-2004, 12:37 AM
I just tried the same processes (both the "get" process and the longer source-code investigation process I proposed) on the amazon.com search function and I always get the "Browser Bug" page. I fiddled around quite a bit with the different <input> and <option> things, as well as the actual query URL, but it never works. Do you think there is a way to do it, or is amazon.com likely just one of those sites where there's no way to make a query URL?

03-15-2004, 04:16 PM
You were right in determining how a form builds a query string, it is just an ampersand separated list of all of the name values pairs in the form appended to the action URL with a question mark.

Some sites simply do not want you to be able to access their information in this manner. Smart sites will enforce the "post" method, meaning that they will not accept information that is sent using the "get" method because they perceive it as less secure. In these situations you will not be able to use a URL you would have to use a form with the "post" method.

Input type of image is just a graphical substitute for the submit button.

03-16-2004, 12:05 AM
Thank you for all your help.

03-16-2004, 03:22 AM
P.S. Some sites will also not allow posts from anywhere other than their domain as well... also, for instance enforcing things such as a random session variable that only exists as long as you're connected to their site...

These are all security issues... you don't want just anyone to post to your form processing script, do ya? :)