php new bie Posted July 23, 2007 Share Posted July 23, 2007 hello, i know this is anoob Q but i need to know how to get some info or line from aweb page . For Ex : when i search in google about something like "phpfreaks.com" without qoute it show the results number at right top about "112,000" here is the point ,, i need to make aform that when i post "phpfreaks.com" without qoute . php load the page in buffer and then print only the result which is "112,000" . any ideas thanks. Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 23, 2007 Share Posted July 23, 2007 do you mean this result Results 1 - 10 of about 4,170,000 for php freaks. (0.13 seconds) Quote Link to comment Share on other sites More sharing options...
php new bie Posted July 23, 2007 Author Share Posted July 23, 2007 yeah , about 4,170,000 i need to print only these numbers on blank page without loading the main page in my browser . Quote Link to comment Share on other sites More sharing options...
redarrow Posted July 24, 2007 Share Posted July 24, 2007 ur need to sort out the rest your self ok if there a word+word your need to use the + ok <?php $x=$_POST['x']; if(isset($x)){ $q=file_get_contents("http://www.google.co.uk/search?hl=en&q=$x&meta="); $a=explode(' ',$q); for($i=153; $i<161; $i++){ echo " <table align='center'><td><tr>$a[$i]</td></tr></table>"; } } ?> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>"> <br> Get google page results for the term word ? <br> <br> <input type="text" name="x"> <br> <br> <input type="submit" name="submit" value="Get results now!"> </form> </center> Quote Link to comment Share on other sites More sharing options...
php new bie Posted July 24, 2007 Author Share Posted July 24, 2007 thank you very much ,, it is work great with some words and thats depends on $i value . I modify it with regular experssion ,, although there is no php errors but it is n't get the value . here the modification : <?php if (isset($_POST['x'])){ $x=$_POST['x']; } if(isset($x)){ $q=file_get_contents("http://www.google.com/search?hl=en&q=$x&btnG=Search"); $sp = ".(about)+(.)+(for)"; $num = ereg($sp,$q,$reg); if ($num) { echo "matched" . "<br />" . "$reg[2]"; } } ?> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>"> <br> Get google page results for the term word ? <br> <br> <input type="text" name="x"> <br> <br> <input type="submit" name="submit" value="Get results now!"> </form> </center> as you see the value of $reg[2] is "_" and is it possible to pass avariable within ereg to get some unknown ranges of letters [a-z] or number [0-9] . thank u again Quote Link to comment Share on other sites More sharing options...
php new bie Posted July 26, 2007 Author Share Posted July 26, 2007 here's the final i do it correctly after some search and reading tuterials <html> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>"> <br> Get google page results for the term word ? <br> <br> <input type="text" name="x"> <br> <br> <input type="submit" name="submit" value="Get results now!"> </form> </center> </html> <?php if (isset($_POST['x'])){ $x=$_POST['x']; } if(isset($x)){ $n = str_replace(" ","+",$x); $q=file_get_contents("http://www.google.com/search?hl=en&q=$n&btnG=Search"); $sp = "about <b>(.*)<\/b> for"; $num = ereg($sp,$q,$reg); if ($num) { echo "<center><br /><font color=green" . substr($reg[0] , 5 , -3) . "</font></center>" ; } else { echo "<center>No result Founded !</center>"; } } ?> thanks redarrow for your help . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.