Jump to content

[SOLVED] How To Get certain info From aweb page ?


php new bie

Recommended Posts

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.

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>

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 :)

 

 

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 .

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.