Its is possible to create search engine by using PHP?

Discussion in 'PHP' started by skyrackson, Jan 23, 2010.

  1. #1
    I planed to create a search engine that searches .exe files in a webpages it is possible to create a search engine with the use of PHP alone and also I need do the Page rank concepts also???
     
    skyrackson, Jan 23, 2010 IP
  2. dmanto2two

    dmanto2two Peon

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    are you searching a directory in your server, or info in a database? the database search is easy. the directory search would be a little harder.
     
    dmanto2two, Jan 23, 2010 IP
  3. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    what is difference between searching directory or information? I need to store the newly designed site into the database and the database should store the full information about the site including the .exe file details, according to the user keywords the list of sites should be listed according to the page rank. I did not need other directory sites help ..
     
    skyrackson, Jan 23, 2010 IP
  4. whitehatseo

    whitehatseo Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, it's very possible. You might want to take a look here for some coding examples: http://www.hotscripts.com/category/php/scripts-programs/search-engines/
     
    whitehatseo, Jan 23, 2010 IP
  5. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for your site whitehatseo. I need some coding example but in that site they giving softwares like that.
     
    skyrackson, Jan 23, 2010 IP
  6. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    anybody is there please help me yar.
     
    skyrackson, Jan 26, 2010 IP
  7. checkblog

    checkblog Well-Known Member

    Messages:
    1,212
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Yes it is possible to easily create .exe search engine. Regarding PR, you need to learn about Google data center.
     
    checkblog, Jan 26, 2010 IP
  8. alextera

    alextera Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Take a look at Zend Lucene, pure PHP search engine based on Java Lucene.
     
    alextera, Jan 26, 2010 IP
  9. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ya thanks for your information.
     
    skyrackson, Jan 30, 2010 IP
  10. DivvyWork

    DivvyWork Peon

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    As has been said... Yes you can create a search engine using php. However, personally, I would use PERL for the actual search process.
     
    DivvyWork, Jan 30, 2010 IP
  11. gr8webseller

    gr8webseller Peon

    Messages:
    1,097
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Ya you can do anything with PHP,,,, there are lots of opensource php scripts for search engine,,,, you can even use google to find and filter the results,,,,
     
    gr8webseller, Jan 31, 2010 IP
  12. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hey I have another doubt I just referred about robot.txt file and also about user-agent scripts. I don't know how the user-agent script will read the robot.txt file. whether any script is there for reading the robot.txt file content??
     
    skyrackson, Feb 2, 2010 IP
  13. Nei

    Nei Well-Known Member

    Messages:
    106
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    170
    #13
    LOL
    It is simple. For example:

    $robots=file_get_contents ('http://microchipinf.com/robots.txt');
     
    Nei, Feb 2, 2010 IP
  14. USWGO

    USWGO Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    You could trey aleadsoft search builder pro because I use that software and it allows php usage and even mysql usage.

    That means you can store all your search engine crawls data in a php file or mysql database.
     
    USWGO, Feb 2, 2010 IP
  15. puppetguy

    puppetguy Peon

    Messages:
    85
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    It will be better this way

    $robots=@file_get_contents ('http://microchipinf.com/robots.txt');
    PHP:
    The @ suppresses errors if the file does not exist.
     
    puppetguy, Feb 3, 2010 IP
  16. Nei

    Nei Well-Known Member

    Messages:
    106
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    170
    #16
    Hm, i suppose that it's useful - to see the errors :)
     
    Nei, Feb 3, 2010 IP
  17. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Iam executing the PHP script I got this errors can any one help what this error indicates.

    "catchable fatal error: Object of class DOM Element could not be converted into string in C:\xampp\htdocs\index.php"

    I got this error while Iam executing the curl script and DOM element.
     

    Attached Files:

    Last edited: Feb 3, 2010
    skyrackson, Feb 3, 2010 IP
  18. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    pls help me yarr
     
    skyrackson, Feb 4, 2010 IP
  19. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #19
    Post code?
     
    krsix, Feb 4, 2010 IP
  20. skyrackson

    skyrackson Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php
    $receivedurl=$_REQUEST["urltxt"];
    $keywords=$_REQUEST["keywordtxt"];
    $desc=$_REQUEST["desctxt"];
    
    echo "<br>".$receivedurl;
    echo "<br>".$keyword;
    echo "<br>".$desc;
    
    $last=strrpos($receivedurl,"/");
    $url=substr($receivedurl,0,$last);
    $homeurl=substr($receivedurl,$last);
    
    echo "<br>".$last;
    echo "<br>".$url;
    echo "<br>".$homeurl;
    include "connection.php";
    $query = "INSERT INTO homesite (urlid, url, homeurl, pagerank, description, keywords) VALUES (NULL, '".$url."', '".$homeurl."',0,'".$desc."','".$keywords."')";
    mysql_query($query);
    echo " Inserted Successfully";
    //$receivedurl=$_REQUEST[urltxtbox];
    $fullurl = "http://".$url;
    echo "<BR>".$fullurl.$homeurl;
    searchLink($url,$homeurl);
    
    function importAgent($target_url)
    {
    //$target_url = "http://".$target_url;
    //$target_url = "http://localhost/aaa/".$receivedurl;
    echo $target_url;
    $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
    
    // make the cURL request to $target_url
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_URL,$target_url);
    curl_setopt($ch, CURLOPT_FAILONERROR, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    $html= curl_exec($ch);
    if (!$html) {
    	echo "<br />cURL error number:" .curl_errno($ch);
    	echo "<br />cURL error:" . curl_error($ch);
    	exit;
    }
    
    // parse the html into a DOMDocument
    $dom = new DOMDocument();
    @$dom->loadHTML($html);
    
    // grab all the on the page
    $xpath = new DOMXPath($dom);
    return $xpath;
    }
    
    function storeLink($software,$fullurl,$url) {
    	include "connection.php";
    	
    	$query="SELECT Name FROM categories";
    	$cat_list = mysql_query($query);
    	
    	$query="SELECT urlid FROM categories where url='".$url."'";
    	$urlid = mysql_query($query);
    	
    	$xpath = importAgent($fullurl);
    	$metas = $xpath->evaluate("/html/head//meta");
    	
    	for ($i = 0; $i < $metas->length; $i++) {
    	$meta = $metas->item($i);
    	$content = $meta->getAttribute('content');
    	echo "META:  ".$meta;
    	while($category=mysql_fetch_array($cat_list)) {
    		if(strpos($content,$category)>=0)
    			{
    			$query = "INSERT INTO antivirus (suburl, software, title, metatag, h1, clicks, urlid) VALUES ('$fullurl', '$software', NULL, '$meta', NULL, NULL, $urlid)";
    			echo "<br> hi";
    			mysql_query($query);// or die('Error, insert query failed');
    			}
    		}
    	}
    }
    
    function searchLink($url, $receivedurl)
    {
    
    $target_url = "http://".$url.$receivedurl;
    $xpath = importAgent($target_url);
    $hrefs = $xpath->evaluate("/html/body//a");
    
    for ($i = 0; $i < $hrefs->length; $i++) {
    	$href = $hrefs->item($i);
    	$linkurl = $href->getAttribute('href');
    	$exe = strrchr($linkurl,".");
    	echo "<BR>".$linkurl." - ";
    	if($exe==".exe")
    	{
    		storeLink($linkurl,$target_url,$url);
    		echo $exe." Succss";
    	}
    	else if($exe==".html" || $exe==".htm" || $exe==".php" || $exe==".asp" || $exe==".aspx" || $exe==".xml" || $exe==".xmls")
    	{
    		$linkurl="/".$linkurl;
    		searchLink($url, $linkurl);
    	}
    	else
    	{
    		echo $exe." Failed";
    	//storeLink($url,$target_url);
    	//echo "<br />Link stored: $url";
    	}
    }
    }
    ?>
    </body>
    </html>
    PHP:

    I got the error in line 81 ?
     
    Last edited: Feb 6, 2010
    skyrackson, Feb 6, 2010 IP