PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,354 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,798 people online right now. Registration is fast and FREE... Join Now!




Displaying search results from multiple websites

 

Displaying search results from multiple websites

Xioshin

2 Jul, 2009 - 01:46 PM
Post #1

D.I.C Head
**

Joined: 5 Nov, 2008
Posts: 213

Hi,

I believe it would be possible to display on my own custom page the search results of other websites. For example, if I type in "apples" on a form on my own website, it would put "apples" into both Google.com and Yahoo.com and then list a number of returned results (we'll say 10 for simplicity's sake).

How exactly would I go about this?

I figured I would have to take the query string from the form and add that to the appropriate URL depending on how each particular website does it, such as http://www.google.com/#hl=en&q=apples.

I would then take this longer URL and what I assumed would be using cURL to get the HTML response of the search and then use regular expressions to pull the data between certain tags (that would also vary depending on which site we were currently getting the results from).


Is this correct? Should I not be using cURL?

Is it even legal to have a website which will pull a response and display it on your own website without their permissions?

This post has been edited by Xioshin: 2 Jul, 2009 - 01:47 PM

User is offlineProfile CardPM
+Quote Post


ShaneK

RE: Displaying Search Results From Multiple Websites

2 Jul, 2009 - 02:54 PM
Post #2

require_once("brain.php"); //Fatal error :/
Group Icon

Joined: 10 May, 2009
Posts: 699



Thanked: 47 times
Dream Kudos: 75
Expert In: PHP, MySQL

My Contributions
That sounds about right. You can also use file_get_contents(), but it's up to you tongue.gif (Also note, no matter your choice, you'll wanna use urlencode.)

Not sure about the legality of taking other sites' contents. I doubt Google would have a problem with it, but who knows? You should probably try locating their terms of service and seeing if they say anything about it. If you can't find anything there, you might wanna try contacting them or something....assuming you wanna be on the absolute safe side.

Yours,
Shane~

This post has been edited by ShaneK: 2 Jul, 2009 - 02:55 PM
User is offlineProfile CardPM
+Quote Post

Xioshin

RE: Displaying Search Results From Multiple Websites

2 Jul, 2009 - 03:15 PM
Post #3

D.I.C Head
**

Joined: 5 Nov, 2008
Posts: 213

Ah file_get_contents.. i was trying to remember the name of the function but was having trouble.

Thanks for your reply. Hopefully people can add more.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 06:58PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month