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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.