How to build a Meta search engine using php and google

1 min read

How to build a meta search engine with PHP

meta search engine is a search tool that sends user requests to several other search engines and/or databases and aggregates the results into a single list or displays them according to their source.Currently there are a lot of meta search engine on internet.For example deeperweb.com is a meta search engine which gives the normal search results of google  combined with  results of  “Answers Search” ,”Metrics Search” ,”News Search” etc.In this tutorial I will show you how to build a meta search engine with PHP .

Meta Search Engine

To build a meta search engine first you need to choose a real search engine and here nothing is better that google.com. Now you need to fetch the content of google search and curl() is the best method for PHP.After fetching the results you need to you need to parse the search results because there are a lot of other things which are useless for you.I have used regular expressions for parsing .After parsing results and exacting main information from content you just need to show the results in your manner.

You can see the demo of my meta search engine script from here.

Here is the source of  this meta search engine.

Meta Search Engine PHP Script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//Date:30-11-2012
//Title:How to build a meta search engine with PHP
//File name:meta-search.php
if(!isset($_GET['q']))$extra='form{
position:absolute;
top:200px;
left:500px;
}';
echo'
Meta Search Engine By megarush.net
.$_GET["q"].'" />
';
if(isset($_GET['q'])){
$q=$_GET['q'];
$dork="";// (optional)specify a dork if you want to use like site:php.net etc
$site="google.com";   // choose any country based search engine by google linke google.co.in ,google.co.uk etc;
$link="http://www.".$site."/search?q=".$q.$dork;
$link=str_replace(" ","%20",$link);
$ch=curl_init();
$useragent="Mozilla/5.0 (compatible; Megarush bot; +http://megarush.net/meta-search-engine-php/)";   //Choose a user agent
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_URL,$link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$content = curl_exec($ch);
curl_close($ch);
//$content =file_get_contents($link);    //if you are unable to use curl then use this method to fetch data
preg_match_all('/
  • .+?<\/li>/',$content,$con);
  • if(count($con[0])==0) echo "No results found";
    for($i=0;$i<count($con[0]);$i++)
    {
    $con[0][$i]=preg_replace('/\/url\?q=/','',$con[0][$i]);
    $con[0][$i]=preg_replace('/\/search\?/','/meta-search.php?',$con[0][$i]);
    $con[0][$i]=preg_replace('/\/imgres\?imgurl=/','http://'.$site."/imgres?imgurl=",$con[0][$i]);
    $con[0][$i]=preg_replace('/\/images\?q=/','http://'.$site."/images?q=",$con[0][$i]);
    $con[0][$i]=str_replace('%3F','?',$con[0][$i]);
    $con[0][$i]=str_replace('%3D','=',$con[0][$i]);
    $con[0][$i]=str_replace('&sa','?&sa',$con[0][$i]);
    echo $con[0][$i];
    }}
    ?>
    </body>
    </html>

     

    You can customize this PHP script by implementing google dork and you can show unique search results .For example if you want to build a video search engine than can use site:youtube.com as a dork to show results only from YouTube.

    Comments (0)

    Leave a Comment

    Type the above code here

    Read Next

    Alternative Loans(for salaried students) HELB Kenya

    1 min read

    Alternative loans(for salaried students)helb kenyaalternative loans comprise of postgraduate (masters & phd) and undergraduate loans for salaried applicants loans. this category of loan was introd...

    Continue reading

    Deadline in 59 Hours Apply now for the IEBC JOBS 2017 Click the link the description or download the online application form

    1 min read

    Deadline in 59 hours apply now for the iebc jobs 2017  click the link the description or download the online application form359,958 iebc temporary jobs are here apply todaythe positions advertis...

    Continue reading

    2017/2018 Second & Subsequent Undergraduate Loans and helb loan checker

    1 min read

    2017/2018 second & subsequent undergraduate loans helb have  opened 2017/2018 second & subsequent loan applications.the application will be closed on 30th june 2017. go to the helbpo...

    Continue reading

    I am Having problems downloading form 1 selection 2016 Form 1 reporting date is 9 th January 2017

    1 min read

    Cs fred matiang'i: all candidates who scored 400 marks and above selected to national schools. 24,795 kcpe candidates have been selected to national schools. 65,331 candidates selected to extra-county...

    Continue reading

    KUCCPS 2018 first Revision and second Revision of Courses Degree, Diploma, Certificate programmes

    1 min read

    Kuccps first revision degree programme/courses in 2018kcse 2017 candidates who attained c+ of 46 points will be in a position to apply for degree courses of their choice so long as they meet the clust...

    Continue reading

    Mpesa Rates 2019 – Safaricom Mpesa Charges and Tariffs (Withdrawal and Transfer)

    2 min read

    Mpesa rates 2019 – safaricom mpesa charges and tariffs (withdrawal and transfer)safaricom mpesa rates, fees, charges and tariffs for withdrawal and transfer depends on the amount you are sending...

    Continue reading