NameSilo

[Resolved] I need Php code for bulk Google "did you mean: ..." results

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

Erdy

VIP Member
Impact
115
I need php code for bulk google "did you mean: ..." results

On google when I type workexperience google says "did you mean: work experience". Or type studenthomes and google will say "Did you mean: student homes".

This is a perfect feature. I want to use this feature in bulk. Do you think you can help me on this?

If it makes your job easier, some time ago Dan had written a php code for bulk google searches to count the number of search results. Maybe you can convert this code to show the words after "did you mean:" part.

PHP:
<?php

$file = file('path/to/your/list/of/words/to/search/for.txt');

$results = '';
foreach ($file as $line) {
	$data     = file_get_contents("http://www.google.com/search?hl=en&q=" . urlencode($line) . "&btnG=Google+Search");
	preg_match('/of about <b>([0-9,]*)?<\/b>/si', $data, $number);
	$results .= $line . " " . $number[1] . "\n";
}
echo $results;

?>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Changed:
Its now $explodeit = explode("
",$file); instead of $explodeit = explode("\r",$file);

I know this has now been resolved but just as a suggestion it's a bit 'cleaner' to use file. file will create an array of a files contents separated by new lines.

PHP:
$explodeit = file($file);

Just a bit better than using explode like you have :)

Matt.
 
0
•••
Yup :) This thread will never die!
 
0
•••
This is all great info.

Thanks for sharing, guys!
 
0
•••
I thought I could make a small addition myself but I'm having no luck. Maybe someone can help.

How would I edit this script so that it displays the original searched term beside the suggestion? This way when working with a longer list I know what to compare.

Thanks.
 
0
•••
warren.davis said:
I thought I could make a small addition myself but I'm having no luck. Maybe someone can help.

How would I edit this script so that it displays the original searched term beside the suggestion? This way when working with a longer list I know what to compare.

Thanks.
Code:
<?
function getGoogleSuggestions($query){

$file = file_get_contents("http://www.google.com/search?q=".urlencode($query));
	if(!eregi("Did you mean", $file)){
		return "No suggestions.";
	}else{
		$ex0 = explode('Did you mean:', $file);
		$ex2 = explode("</i></b>", $ex0[1]);
		$ex3 = explode("class=p>",$ex2[0]);
		$ex4 = str_replace('<b><i>', '', $ex3[1]);
		return "Did you mean: ".$ex4;
	}
}
$file = file_get_contents('words.txt');
$explodeit = explode("
",$file);
foreach($explodeit as $value) {
$query = trim($value);
echo $value. " - " .getGoogleSuggestions($query).'<br>';
}
?>

Should do it for you :P
 
0
•••
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover

NamePros updates

New in Parking: updated way to act on many domains or inquiries at once
Your domain list and inquiry list now have a bar above and below the list. Check the items you want, then choose an action in the bar...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back