Hi,
I am trying to make a search engine which will run a search on google. I want the search results to be displayed on my site in the format I want. So far I have been able to run the search and get the contents on my page but I want to know how can I format that data into an HTML page I want(like having my own tables to display the results).
I am attaching the code that I wrote for it. Please can someone explain me this logic so that I can work with it in the future.
I have a file search.php which has a form where the user enters the SearchString and on clicking submit calls the result.php page which performs the search on google and displays the result on that page.
search.php
//<?
//echo "<title>Search Engine</title>";
//echo "<form name=search_form action='result.php'>\n";
//echo "<input type=text name=SearchString value='' size=15>";
//echo "<br>";
//echo "<br>";
//echo "<input type=submit value=search></form>\n";
//echo "";
//?>
This is the result.php page
//<?
//$SearchString = urlencode($SearchString);
//if ( $SearchString == '' ) {
//echo "Please fill in the edit box";
//}
//else {
//$submit_url = "http://www.google.com/search?q=$SearchString&hl=en&lr=&safe=off";
//$file = fopen($submit_url, "r");
//$rf = fread($file, 50000);
//$rf = eregi_replace("<head>.*</head>","<head><title>Mandy's //Search Engine</title></head>",$rf);
//echo $rf;
//fclose($file);
//}
//?>
Now this perfectly displays the results but in the format that google uses on it's page. So should I see the source of the google's result page and then do a eregi_replace for all the elements or is there a smarter way to do it. I am also having problems replacing the img tags cos they r followed by lot of content like src, border etc so how can a wildcard be used with it.
like eregi_replace("<img *>","",$rf); this doesn;t work ...i searched this database but couldn't find a proper answer to this..i am sorry if i missed something
regards,
mandy.