NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] I need php code for bulk google "did you mean: ..." results

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 01-06-2007, 01:37 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



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 Code:
<?php

????: NamePros.com http://www.namepros.com/programming/277647-resolved-i-need-php-code-bulk.html
$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;

?>
Erdy is offline  
Old 01-06-2007, 02:10 AM   #2 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Do you have a Google SOAP API key for your site yet?
If you do, then you could use nusoap and SOAP to tap into google's built in spell-checker:

Download Nusoap Toolkit, extract just nusoap.php from inside the archive (its in the lib folder of the archive)
http://prdownloads.sourceforge.net/n...2.zip?download

Then create a PHP file:
PHP Code:
// put your developer's key here:
$key 'INSERT GOOGLE API DEVELOPERS KEY';

????: NamePros.com http://www.namepros.com/showthread.php?t=277647
include (
'nusoap.php');

$soapclient = new soapclient('http://api.google.com/search/beta2');
$soapoptions 'urn:GoogleSearch'
And below that, if you want to do a spelling suggestion:
PHP Code:
function do_spell$q$key, &$spell )
{
    global 
$soapclient;
    global 
$soapoptions;
????: NamePros.com http://www.namepros.com/showthread.php?t=277647
    
    
$params = array(
                
'key' => $key
                
'phrase' => $q
        );

    
$spell $soapclient->call('doSpellingSuggestion'$params$soapoptions);

    
$err $soapclient->getError();

    if (
$err)
    {
        print(
"<br>An error occurred!<br>");
        print(
" Error: $err<br>\n");
        return 
false;
    }

    return 
true;

Wherever you want the script to check you just do:
PHP Code:
$Query 'workexperience'//Put search term here
do_spell($Query$key$spell);
          if (
$spell[0]) {
            print 
"Did you mean <b><a href=\"../search/?q=".$spell."\">".$spell."</a></b>? ";
          } 
beaver6813 is offline  
Old 01-06-2007, 10:13 AM   #3 (permalink)
NamePros Regular
 
cvxdes's Avatar
Join Date: Oct 2005
Location: Milford MA
Posts: 692
cvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud of
 



Or.... you can use this:
(Just written)

Code:
<?
function getGoogleSuggestions($query){
	$file = file_get_contents("http://www.google.com/search?q=".$query);
	if(!eregi("Did you mean", $file)){
		return "No suggestions.";
	}else{
		$ex0 = explode('Did you mean:', $file);
		$ex1 = str_replace('</i></b>', '<b><i>', $ex0[1]);
		$ex2 = explode("<b><i>", $ex1);
		return "Did you mean: ".$ex2[1];
	}
}

$query = "studentexperience";
echo getGoogleSuggestions($query);
?>
(Feel free to leave rep or NP)
cvxdes is offline  
Old 01-06-2007, 10:28 AM THREAD STARTER               #4 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



beaver6813,
These are too complicated for me. I'm just an average computer user. Thank you anyway for your great effort.

cvxdes,
I think this is closer to what I need but can you make the code so that it reads the input list from a text file. For instance on my first message you see Dan's code. There is this line:
$file = file('path/to/your/list/of/words/to/search/for.txt');
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

I'm using this method. What happens is that I put 400 words on my data file. I have different php files for different search types like this:

bulksearch.php
picturesearch.php
frooglesearch.php
inurlsearch.php

All these searches get the data from the same text file. So leaving the text file at the same place I click on different php files. Now I want to add one didyoumean.php file to that list. It should read the same text file like dan's code.
Erdy is offline  
Old 01-06-2007, 01:20 PM   #5 (permalink)
NamePros Regular
 
cvxdes's Avatar
Join Date: Oct 2005
Location: Milford MA
Posts: 692
cvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud of
 



Is the text file comma seperated or is it seperated by lines... or what is it seperated by?
cvxdes is offline  
Old 01-06-2007, 04:32 PM THREAD STARTER               #6 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



Hi cvxdes,
It is seperated by lines.
Erdy is offline  
Old 01-07-2007, 02:15 AM   #7 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Originally Posted by MarcelProust
Hi cvxdes,
It is seperated by lines.
Hey,
Modified cvxdes's code

Code:
<?
function getGoogleSuggestions($query){

	$file = file_get_contents("http://www.google.com/search?q=".$query);
	if(!eregi("Did you mean", $file)){
		return "No suggestions.";
	}else{
		$ex0 = explode('Did you mean:', $file);
		$ex1 = str_replace('</i></b>', '<b><i>', $ex0[1]);
		$ex2 = explode("<b><i>", $ex1);
		return "Did you mean: ".$ex2[1];
	}
}
$file = file_get_contents('words.txt');
$explodeit = explode("\r",$file);
foreach($explodeit as $value) {
$query = trim($value);
echo getGoogleSuggestions($query).'<br>';
}
?>
That will get all words from the file words.txt and go through each line checking, then return all suggestions, example:
????: NamePros.com http://www.namepros.com/showthread.php?t=277647
http://www.beaver6813.com/temp/TESTNAMEPROS.php

The words.txt contains:
Code:
workexperience
pakaging
beaver6813 is offline  
Old 01-07-2007, 05:25 AM THREAD STARTER               #8 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



Hello beaver6813,

Thank you for your effort. It was very nice of you to show a working example of it. On the other hand when I try there is a small problem. Only when the text file has one line then it works. Otherwise it doesn't. For instance when I insert our example keywords,
Code:
workexperience
pakaging
it says
Code:
No suggestions.
Only when I remove the second line on the text file and leave the first line the it says
Code:
Did you mean: work experience
I don't know what I'm doing different than you. Are you sure you have copied the php code from your working file?
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

Either of you please help. I really need this feature.
Erdy is offline  
Old 01-07-2007, 06:50 AM   #9 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,568
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
First of all this is a terrible way to do it lol. This is going to kill your pages execution time, wouldn't be surprised it increased it x4 or more. Atthe very least use curl instead of file_get_contents which is extremely slower.

beaver6813's initial suggestion of using the Google API is far, far better and is not actually that complicated.


Anyway, MarcelProust i have tried the code given and it works fine.

Could you show us how you are using it?
Matthew. is offline  
Old 01-07-2007, 11:12 AM   #10 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Heh, it doesn't really matter which way he does it, it'll be hard for him to get a SOAP api key anyways for google now because they've stopped officially supporting it, they're trying to get people to use their Ajax Search instead which is quite frankly too limiting and doesn't have spell check.

I don't know why it isn't working for you... ill upload the exact file somewhere... maybe youve uploaded it wrong :S Works fine for me

You should be able to download here: http://www.beaver6813.com/temp/TESTNAMEPROS.php.bak
beaver6813 is offline  
Old 01-07-2007, 11:22 AM   #11 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,568
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
Originally Posted by beaver6813
Heh, it doesn't really matter which way he does it, it'll be hard for him to get a SOAP api key anyways for google now because they've stopped officially supporting it, they're trying to get people to use their Ajax Search instead which is quite frankly too limiting and doesn't have spell check.
Aren't the API keys the same for all services though? Talking blind here, haven't used or look at it in a couple of years
Matthew. is offline  
Old 01-07-2007, 11:29 AM   #12 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Originally Posted by Matthew.
Originally Posted by beaver6813
Heh, it doesn't really matter which way he does it, it'll be hard for him to get a SOAP api key anyways for google now because they've stopped officially supporting it, they're trying to get people to use their Ajax Search instead which is quite frankly too limiting and doesn't have spell check.
Aren't the API keys the same for all services though? Talking blind here, haven't used or look at it in a couple of years
Nah they're not They no longer provide SOAP API Keys for domains, only existing api keys will still work, i used a lot of search engine stuff whilst working on twerq.com so im in the know when it comes to google api lol Yahoo on the other hand are much nicer and has less limits and provide more support for their API Yahoo aren't evil, but google are
beaver6813 is offline  
Old 01-08-2007, 07:31 PM THREAD STARTER               #13 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



Hello,
It appears its only me who can't get this working. This is somewhat strange because if there is one word one first line it works. So the php file reads the data from text file but for some reason in most cases it doesnt read correctly. I have been experimenting with this for a while.

If the first line has one word like "workexperience" and any other line is blank than it works. If I put anything on the second line, any word or even a dot than it doesnt work.
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

On the first line if I put "good norning" and don't put anything on other lines it doesn't work. Somehow the space between these words causes a problem. I've got this error after this try:

Code:
Warning: file_get_contents(http://www.google.com/search?q=good norning) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/.../public_html/.../domiansearch/TESTNAMEPROS.php on line 4
No suggestions.
So I go back to the text file remove the space and leave "goodnorning". Now it works again.

What am I doing wrong. On cpanel file manager I create a file and name it as filename.php. Than I click edit file and paste the code I copy from beaver6813's message. This is rather strange since my other php file bulkgooglesearch.php, work just perfect.
Erdy is offline  
Old 01-09-2007, 12:21 AM   #14 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




I think i forgot the urlencode

Code:
	$file = file_get_contents(urlencode("http://www.google.com/search?q=".$query));
I've changed that line with urlencode, so queries with spaces in them should now work, although if it still doesn't work for you, pm me the cpanel details and where it is etc and ill take a look
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

The whole script should now be:
Code:
<?
function getGoogleSuggestions($query){

$file = file_get_contents(urlencode("http://www.google.com/search?q=".$query));
	if(!eregi("Did you mean", $file)){
		return "No suggestions.";
	}else{
		$ex0 = explode('Did you mean:', $file);
		$ex1 = str_replace('</i></b>', '<b><i>', $ex0[1]);
		$ex2 = explode("<b><i>", $ex1);
		return "Did you mean: ".$ex2[1];
	}
}
$file = file_get_contents('words.txt');
$explodeit = explode("\r",$file);
foreach($explodeit as $value) {
$query = trim($value);
echo getGoogleSuggestions($query).'<br>';
}
?>
beaver6813 is offline  
Old 01-09-2007, 11:17 AM THREAD STARTER               #15 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



Hello beaver,
Thanks for your patience. Unfortunately this second code doesn't work at all. The previous code at least worked when there is only one word only on the first line. This second code did not work in any case. Is there absolutely no way to write a smillar code to Dan's which is in my first message. It works perfect for bulk search results. No matter what I put on any line it searches it on google and returns me the count.
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

Here is some information about my cpanel:
Code:
General server information: 
Operating system Linux 
Service Status Click to View 
Kernel version 2.6.9-42.0.3.ELsmp 
Machine Type i686 
Apache version 1.3.37 (Unix) 
PERL version 5.8.7 
Path to PERL /usr/bin/perl 
Path to sendmail /usr/sbin/sendmail 
Installed Perl Modules Click to View 
PHP version 4.4.4 
MySQL version 4.1.21-standard 
cPanel Build 10.9.0-CURRENT 117 
Theme cPanel X v2.6.0  
Documentation Click to View 
cPanel Pro 1.0 (RC36)
Let me summarize:

I. I'm using the previous code on message #7:
I put this on the text file:
Code:
workexperience
And ı get this result:
Code:
Did you mean: work experience
So it works fine. Then I put this in the text file:
Code:
workexperience
pakaging
and I get this result:
Code:
No suggestions.
Lastly I put this in the text file:
Code:
good norning
and get this result:
Code:
Warning: file_get_contents(http://www.google.com/search?q=good norning) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/.../public_html/.../domiansearch/didyoumean.php on line 4
No suggestions.
II. Now I'm using your second code on message #14.
text file:
Code:
workexperience
result:
Code:
Warning: file_get_contents(http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dworkexperience) [function.file-get-contents]: failed to open stream: No such file or directory in /home/.../public_html/.../domiansearch/didyoumean.php on line 4
No suggestions.
Text file:
????: NamePros.com http://www.namepros.com/showthread.php?t=277647
Code:
workexperience
pakaging
Result:
Code:
Warning: file_get_contents(http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dworkexperience%0Apakaging) [function.file-get-contents]: failed to open stream: No such file or directory in /home/.../public_html/.../domiansearch/didyoumean.php on line 4
No suggestions.
Lastly, text file is
Code:
good norning
And the result is
Code:
Warning: file_get_contents(http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dgood+norning) [function.file-get-contents]: failed to open stream: No such file or directory in /home/.../public_html/.../domiansearch/didyoumean.php on line 4
No suggestions.
Erdy is offline  
Old 01-09-2007, 01:17 PM   #16 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Right this has gotta work lol, i've rewritten even more of the script, i don't have time to optimize it or anything at the moment so its just a really quick job, but it works
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

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("\r",$file);
foreach($explodeit as $value) {
$query = trim($value);
echo getGoogleSuggestions($query).'<br>';
}
?>
Changed:
Posistion of URLEncode so it only applies to query string.
The way the script removes all other junk from the page, i had to do this so it could retrieve the right spelling for queries with more than one word. like good morning
When running this script i got the response:
Code:
Did you mean: work experience
Did you mean: packaging
Did you mean: good morning
So it appears to be working My words.txt is currently:
Code:
workexperience
pakaging
good norning
beaver6813 is offline  
Old 01-09-2007, 06:24 PM THREAD STARTER               #17 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



Hello beaver,

Unfortunately it doesn't work. The different lines are not recognized by the script. It reads them as if they were all on the same line.

I don't know why it works for others and not for me. At the beginning I thought this would be something very easy to solve.
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

On Dan's code what is different that makes it work without a problem? Again there is a text file and again it reads whatever is on each line. It doesn't matter if there are multiple words on lines or how many lines there are and it always works smooth. I think the way Dan's scrips gets the data from the text file is different than what we are trying and for some unknown reason the former works while the latter doesn't.

I'm sorry for being a troublemaker on this issue especially when the title already says "resolved" and when others have reported it works for them.
Erdy is offline  
Old 01-10-2007, 12:37 AM   #18 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Originally Posted by MarcelProust
Hello beaver,

Unfortunately it doesn't work. The different lines are not recognized by the script. It reads them as if they were all on the same line.

I don't know why it works for others and not for me. At the beginning I thought this would be something very easy to solve.

On Dan's code what is different that makes it work without a problem? Again there is a text file and again it reads whatever is on each line. It doesn't matter if there are multiple words on lines or how many lines there are and it always works smooth. I think the way Dan's scrips gets the data from the text file is different than what we are trying and for some unknown reason the former works while the latter doesn't.
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

I'm sorry for being a troublemaker on this issue especially when the title already says "resolved" and when others have reported it works for them.
Lol i seriously don't know why its not working for you Okay since you said its reading it all as one line, i've changed the explode part of the script, its not as neat but it may work for your version. PM me with any IM you have to we can get this sorted faster

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 getGoogleSuggestions($query).'<br>';
}
?>
Changed:
Its now $explodeit = explode("
",$file); instead of $explodeit = explode("\r",$file);
beaver6813 is offline  
Old 01-10-2007, 03:44 AM THREAD STARTER               #19 (permalink)
Senior Member
Join Date: Sep 2006
Location: London, UK
Posts: 1,922
Erdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond reputeErdy has a reputation beyond repute
 



It works, it works!
Thank you so much beaver for you great effort and for your patience on this. Now it is resolved. I've put 200 words in the text file and as I saw the results page opening 2 words per second, the list growing bigger and bigger, it was like dominos were falling. So beautiful. Repetition and some namebuck added to both of you. Thanks.
Erdy is offline  
Old 01-10-2007, 09:27 AM   #20 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Originally Posted by MarcelProust
It works, it works!
Thank you so much beaver for you great effort and for your patience on this. Now it is resolved. I've put 200 words in the text file and as I saw the results page opening 2 words per second, the list growing bigger and bigger, it was like dominos were falling. So beautiful. Repetition and some namebuck added to both of you. Thanks.
All in a days work
beaver6813 is offline  
Old 01-10-2007, 09:32 AM   #21 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,568
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
Quote:
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 Code:
$explodeit file($file); 
Just a bit better than using explode like you have
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

Matt.
Matthew. is offline  
Old 01-10-2007, 09:39 AM   #22 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Yup This thread will never die!
beaver6813 is offline  
Old 01-10-2007, 10:36 AM   #23 (permalink)
Account Closed
Join Date: Sep 2006
Posts: 1,075
YesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to all
 



This is all great info.

Thanks for sharing, guys!
YesBrilliant is offline  
Old 01-30-2007, 05:22 PM   #24 (permalink)
Account Closed
Join Date: Aug 2006
Posts: 234
warren.davis will become famous soon enoughwarren.davis will become famous soon enough
 



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.
warren.davis is offline  
Old 01-30-2007, 08:28 PM   #25 (permalink)
Senior Member
 
Chicken's Avatar
Join Date: Oct 2005
Posts: 1,089
Chicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud ofChicken has much to be proud of
 


Save The Children Save The Children Save The Children Save The Children
Originally Posted by warren.davis
I thought I could make a small addition myself but I'm having no luck. Maybe someone can help.
????: NamePros.com http://www.namepros.com/showthread.php?t=277647

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
__________________
Quit developing - Jan 2012
Chicken is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:08 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger