Page 1 of 1

Question

Posted: Wed Sep 30, 2009 4:46 pm
by optivader
Hello guys, girls,

I would like to know if it is possible to have a search form on website A that would search site B using site B's search Bar. Example : If I type "apple" on Site A and press Search, could the results for the search "apple" through hobbytron.com open in a new window. I sincerely have no clue if this can be done.

thanks

vader vader

Re: Question

Posted: Wed Sep 30, 2009 5:16 pm
by peterjwest
Lets use an example: imagine you want to use your site, http://www.buystuff.com, to search http://www.amazon.com. The user can enter search terms into a search bar on your site.

Do you want to display the search results on your site or on amazon? If the answer is amazon then its fairly straightforward, you just need to redirect the browser to the appropriate URL on amazon:
header( "Location: http://www.amazon.com/s/ref=nb_ss?$searchTerms" );
where $searchTerms will be something like:
$searchTerms = "?search=wireless+router+netgear"

You'll need to know the search format for the site. For amazon you can use something like:
header( "http://www.amazon.co.uk/s/ref=nb_ss?url ... tr_replace(' ','+',$searchTerms));
This is very crude, you should probably filter the search terms to be URL characters only, among other things.

If you want to display the results on your site it's more complicated.

Re: Question

Posted: Wed Sep 30, 2009 5:35 pm
by cpetercarter
Adding a google search box to a web site is very easy - see for example http://www.askdavetaylor.com/how_can_i_add_a_google_search_box_to_my_web_site.html. You will see that you can limit the search to a single site by means of an input value "sitesearch". Normally folk use this to create a search facility for their own site, but it can equally well be used for searching a different site (provided, of course, that google has been able to index it).

Re: Question

Posted: Wed Sep 30, 2009 7:11 pm
by califdon
optivader wrote:Hello guys, girls,

I would like to know if it is possible to have a search form on website A that would search site B using site B's search Bar. Example : If I type "apple" on Site A and press Search, could the results for the search "apple" through hobbytron.com open in a new window. I sincerely have no clue if this can be done.

thanks

vader vader
Be sure you understand that doing this without the permission of site B may subject you to a lawsuit by site B, whose owners may consider the content and operation of their site as their property.

Re: Question

Posted: Wed Sep 30, 2009 9:49 pm
by optivader
Thaaaaanks guys for the quick reply.

For your information, I plan on displaying the results within their original website. I will not appropriate the results on my website.

With respect to the Amazon example, I understand that it should be fairly easy, however, some website (hobbytron.com for example, and every website managed with drupal and others) will not have a distinct url for each search.

hobbytron for instance will return "hobbytron.com/search/index.php" whether the search was apple or orange. It's the mechanism behind this type of search bar that I would like to understand.

Thanks to all

vader vader

Re: Question

Posted: Sat Oct 03, 2009 11:13 am
by optivader
Any ideas ?

Thanks

Re: Question

Posted: Mon Oct 05, 2009 8:26 am
by peterjwest
hobbytron for instance will return "hobbytron.com/search/index.php" whether the search was apple or orange. It's the mechanism behind this type of search bar that I would like to understand.
That's because the search information is sent using POST, which is invisible to the URL. An easy way to do this would be to use a form with method POST to send the correct info to the other website. For example:

Code: Select all

<form method="post" action="http://www.hobbytron.com/search/index.php"> 
<input type="text" name="terms"/>
<input type="submit" value="Search!"/>
</form>
You'll need to see what inputs the particular website used, the easiest way to do this would be to inspect the source code of the website's search form.

Re: Question

Posted: Mon Oct 05, 2009 8:45 am
by jackpf
Don't know if this has come up already, but you could use an iframe. Or cURL.

Or even AJAX.

Re: Question

Posted: Mon Oct 05, 2009 5:43 pm
by optivader
Many thanks for the help guys,

I will look into it in details