Dynadot — .com Registration $8.99

PHP script to gather results?

Spaceship Spaceship
Watch

mulligan

Established Member
Impact
15
I'm looking for something that can tell me the total number of results for X number of words.

Basically I need something that I can input a string of words into, one on each line (words will be in many different languages) and will return the total number of results for each word.

I just need the number from the bit at the top of the google results page .. the bit that says 'Results 1 - 10 of about 73,100,000 for "words"'

I just need the number .. 73,100,000
So the output would look like:

words 73,100,000
españa 67,800,000
адресная 1,560,000
大坂山 19,800

(Bearing in mind I will mainly be checking for results in languages like Chinese, Korean, Hindi, Spanish etc)

The number would have to reflect the total number of results within "double quotes" for an accurate reflection of the total.

Just a simple script, something I can run from my browser, maybe a desktop app or run from a server?
Doesn't have to save the results, I can just copy and paste them.

Anybody know of such a thing?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
My first question to you is where are the words stored at. in a db? or are you using google to query a word and then get that number like mentioned in your post
 
0
•••
PHP:
<?php function get_page($url, $ref = "", $user = "", $timeout = "")
{
    if (!function_exists('curl_init') or !function_exists('curl_exec'))
    {
        return file_get_contents($url);
    }
    else
    {
        if (!$timeout)
        {
            $timeout = 10;
        }
        if (!$user)
        {
            $user = "Microsoft Internet Exploder";
        }
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_REFERER, $ref);
        curl_setopt($ch, CURLOPT_USERAGENT, $user);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        $output = curl_exec($ch);
        curl_close($ch);
        return $output;
    }
}

if (!function_exists(strip_by_cap))
{
    function split_by_cap($string)
    {
        $output = "";
        foreach (str_split($string) as $char)
        {
            strtoupper($char) == $char and $output and $output .= " ";
            $output .= $char;
        }
        return $output;
    }
}

if (!function_exists(say))
{
    function say($str, $strip = 0)
    {
        if ($strip and get_magic_quotes_gpc())
        {
            $str = stripslashes($str);
        }
        echo $str;
        ob_flush();
        flush();
        return;
    }
}

if (!function_exists(sayln))
{
    function sayln($str, $strip = 0)
    {
        if ($strip and get_magic_quotes_gpc())
        {
            $str = stripslashes($str);
        }
        echo $str . "<br />\n";
        ob_flush();
        flush();
        return;
    }
}

if (empty($_POST['list']))
{ ?>

<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
Domains:<br />
<textarea name="list" rows="15" style="width:80%;">
SemiAbove.com
SpeakNames.com
CryOwnage.com
WhileBurn.com
NineJournal.com
CostDaily.com
SendTop.com
BoxBoth.com
CenterReseller.com
ScamIf.com
GuessTracker.com
MayWhy.com
ProductLess.com
ScoreTutorial.com
OfferOwnage.com
</textarea><br />
Put "" around the string: <input type="checkbox" checked name="apos" value="true" /><br />
<!-- Not good for foreign chars --><!-- Split by cap <input type="checkbox" name="splitbycap" value="true" /><br /> -->
Strip extension <input type="checkbox" checked name="stripext" value="true" /><br />
<input type="submit" value="Grab Results" />
</form>

<?php
}
else
{
    $list = $_POST['list'];
    $list = str_replace("\r", "", $list);
    $list = explode("\n", $list);

    sayln("Scanning " . count($list) .
        " domains for Google Results, please wait... <br />\n\n");

    foreach ($list as $l => $key)
    {
        unset($out);

        if (isset($_POST['stripexp']))
        {
            $key = explode(".", $k);
            $key = $key[0];
        }

        if (isset($_POST['splitbycap']))
        {
            $key = split_by_cap($key);
        }

        if (strlen($key) > 1)
        {
            if (!isset($_POST['apos']))
            {
                $page = "http://www.google.com/search?q=" . urlencode($key);
            }
            else
            {
                $page = "http://www.google.com/search?q=" . urlencode('"' . $key . '"');
            }

            $p = @get_page($page);
            preg_match_all("/of about <b>([0-9,]*)<\/b> for <b>/", $p, $out);
            if (!$out[1][0])
            {
                $out[1][0] = (int)0;
            }
            say($key ." - " . $out[1][0] . " results<br />\n",1);
        }
    }

    echo '<br /><br /><a href="' . $_SERVER['SCRIPT_NAME'] . '">Again?</a>';

} ?>

Example output:

words - 517,000,000 results
españa - 606,000,000 results
адресная - 1,450,000 results
大坂山 - 11,200 results
 
Last edited:
5
•••
Nice! Does just what I wanted.

NP sent

Thanks :)
 
Last edited:
0
•••
wow, that just blew my mind...i can only offer you a 1+. very well done
 
0
•••
Nice code, i have added some rep point :D
 
0
•••
Great script Danltn. Repped for your effort.
 
0
•••

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back