Question
Moderator: General Moderators
Question
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
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
-
peterjwest
- Forum Commoner
- Posts: 63
- Joined: Tue Aug 04, 2009 1:06 pm
Re: Question
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.
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.
-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: Question
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
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.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
Re: Question
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
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
Any ideas ?
Thanks
Thanks
-
peterjwest
- Forum Commoner
- Posts: 63
- Joined: Tue Aug 04, 2009 1:06 pm
Re: Question
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: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.
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>Re: Question
Don't know if this has come up already, but you could use an iframe. Or cURL.
Or even AJAX.
Or even AJAX.
Re: Question
Many thanks for the help guys,
I will look into it in details
I will look into it in details