Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: Special Search!

  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Special Search!

    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:

    http://www.lukesearch.com/search?=metallica

    ...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!
    - Luke Muehlhauser

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    You don't have to use a form if they allow you to use the get method. Since this works:

    Code:
    http://www.allmusic.com/cg/amg.dll?P=amg&opt1=1&sql=metalica
    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:
    1=artists
    2=albums
    3=songs
    4=labels
    5=styles

  • #3
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow! MAGIC!

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

    THANKS SO MUCH!
    - Luke Muehlhauser

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #5
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    - Luke Muehlhauser

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #7
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!
    - Luke Muehlhauser

  • #8
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Heh, looks like we were posting replies at the same time. Okay, thanks, I'll try the "GET" method to reverse-engineer query URLs.

    THANKS!
    - Luke Muehlhauser

  • #9
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    - Luke Muehlhauser

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.

  • #11
    New Coder
    Join Date
    Mar 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for all your help.
    - Luke Muehlhauser

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •