Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Extract data from any website. (http://www.go4expert.com/forums/extract-data-website-t28419/)

Alex.Gabriel 20May2012 22:59

Extract data from any website.
 
I have created this small code as an example for what this script can do. As everybody know vBulletin is a powerfull board cand can't be tricked easily.
I have used G4F as example , i hope shabbir will not get angry :D
PHP Code:

<html>
    <head><title>Fetch info from any website.</title></head>
    <body>
    <center>
    <form action="gfe.php" method="post">
    <input type="text" name="searchinfo" value=""/>
    <input type="submit" value="Get info"/>
    </form>
    <?php
   
// created by Alex Gabriel
  // http://ethicalforums.com
    
function a($string$start$end){
    
$string " ".$string;
    
$ini strpos($string,$start);
    if (
$ini == 0) return "";
    
$ini += strlen($start);    
    
$len strpos($string,$end,$ini) - $ini;
    return 
substr($string,$ini,$len);
    }
    
$test=$_POST['searchinfo'];
    if (
$test == ""){
    echo 
"Please insert any value";
    }
    else {
    
$source file_get_contents ("http://www.go4expert.com/search.php?do=process&query=$test");
    if (
stripos(strtolower($source), 'Sorry - no matches.') !== false) {
    echo 
'No results found.';
    exit();
    }
    else 
    {
    
$code_first_part a($source,'id="thread_title_','<span class="smallfont"');    
    
    
//thread id
    
$id=a($source,'<a rel="nofollow" href="showthread.php?t=','&amp;');
    
//cleaning some stuff
    //title
    
$title a($code_first_part,'">','</a>');
    
?>
    <a rel="nofollow" href="http://www.go4expert.com/showthread.php?t=<?php echo $id;?>"><?php echo $title?></a>
    <?php
    
}
    }
    
?>
    </center>
    </body>
    </html>

This script will return the first result of any search peoples make on G4F on any website where this code is used. I have't made this script to show all the responses of a search query since i am not interested on this .

shabbir 20May2012 23:23

Re: Extract data from any website.
 
No I am perfectly fine with this as long as it does not query too many times.

Alex.Gabriel 20May2012 23:24

Re: Extract data from any website.
 
That's why i allowed only 1 response to be seen.


All times are GMT +5.5. The time now is 07:32.