google suggest scraper - free php script

Status
Not open for further replies.
I thought the result counts are worth keeping so I modded your code to output an array with the keyword as the key and result count as the value. That way you can simply ignore the counts if not needed. It may be a quick and dirty way to track niche growth over time if you're inclined to write to a db.

Code:
function text_between($start,$end,$string) {
  $keyword = '';
  if ($start != '') {$temp = explode($start,$string,2);} else {$temp = array('',$string);}
  $temp = @explode($end,$temp[1],2);
  $temp2 = @explode($end,$temp[1],3);
  $pages = (int)@str_replace(',','',$temp2[1]); 
  if ($pages) $keyword[$temp[0]] = $pages;
  return $keyword;
}

function gsscrape($keyword) {
  $keyword=str_replace(" ","+",$keyword);
  global $kw;
  $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&gl=uk&q='.$keyword);
  
  $data=explode('[',$data,3);
  $data=explode('],[',$data[2]);
  foreach($data as $temp) {
    $kx = text_between('"','"',$temp);
    if (is_array($kx)) $kw[key($kx)] = current($kx);
  }
}
#simple to use, just use yourscriptname.php?keywords
if ($_SERVER['QUERY_STRING']!='') {
  gsscrape($_SERVER['QUERY_STRING']);
  foreach ($kw as $keyword => $pages) {
      gsscrape($keyword);
  }
}
#all results are in array $kw...
print_r($kw);
Here's some (truncated) output:
Code:
(
    [angelina jolie tattoos] => 455000
    [angelina jolie films] => 14000000
    [angelina jolie twins] => 4010000
    [angelina jolie movies] => 1640000
    [angelina jolie new film] => 1760000
    [angelina jolie wiki] => 985000
    [angelina jolie and brad pitt] => 1470000
    [angelina jolie pictures] => 4470000
    [angelina jolie imdb] => 933000
    [angelina jolie pregnant] => 4110000
    [angelina jolie tattoos and meanings] => 53200
    [angelina jolie tattoos wanted] => 178000
    [angelina jolie tattoos in wanted] => 106000
    [angelina jolie tattoos 2008] => 324000
    [angelina jolie tattoos billy bob] => 42400
    [angelina jolie tattoos coordinates] => 8050
    [angelina jolie tattoos mean] => 307000
    [angelina jolie tattoos pictures] => 399000
    [angelina jolie tattoos explained] => 26600
    [angelina jolie tattoos how many] => 531000
    [angelina jolie films 2008] => 950000
    [angelina jolie films list] => 1420000
    [angelina jolie films 2007] => 481000
    [angelina jolie films online] => 729000
    [angelina jolie films wikipedia] => 111000
    [angelina jolie twins pictures] => 483000
    [angelina jolie twins names] => 1680000
(clipped here)
 


Color me stupid, but where is the code/or google getting the list of keywords i.e. if I pass Angelina Jolie what is the basis of all of the variations?
 
What!? some guy was trying to sell this shit for $29??

Some people are fucking stupid..

This is only useful if you want to integrate it into a script - which suggests you need to know php.. And if you know php, you would never pay money for it.

I did something similar to this for my wordpress auto commenter and it took 5 minutes.. I used it to find more keywords to find wordpress blogs with.

This is a really useful tool to have to integrate into any script to give the script more keywords to work with.

Thanks for sharing BlackBanana
 
BackBanana just wanted to thank you for this script.
This made me register with wickedfire and to my surprise I already saw some familiar faces... I'll stick around.

Just added a tiny little thing that makes your script even more powerful:

PHP:
$abc = array(a,b,c,....,z);
foreach ($abc as $abecedario) {    gsscrape($palav . ' ' . $abecedario);  }
Cheers
 
BackBanana just wanted to thank you for this script.
This made me register with wickedfire and to my surprise I already saw some familiar faces... I'll stick around.

Just added a tiny little thing that makes your script even more powerful:

PHP:
$abc = array(a,b,c,....,z);
foreach ($abc as $abecedario) {    gsscrape($palav . ' ' . $abecedario);  }
Cheers

For the script kiddies in the room (Me) What does that do?

Where does it go?
 
What!? some guy was trying to sell this shit for $29??

Some people are fucking stupid..

This is only useful if you want to integrate it into a script - which suggests you need to know php.. And if you know php, you would never pay money for it.

I did something similar to this for my wordpress auto commenter and it took 5 minutes.. I used it to find more keywords to find wordpress blogs with.

This is a really useful tool to have to integrate into any script to give the script more keywords to work with.

Thanks for sharing BlackBanana

Its hardly stupid. It'd've taken me ~20 minutes to write that, and the average WickedFire member (who probably isn't an experienced programmer - we're marketers around here) up to an hour to figure out. If your time is worth $29 / hour, then yeah, sure, code it yourself, but: if I needed it, I certainly would've bought it @ $29.

Until it was made free...
 
For the script kiddies in the room (Me) What does that do?

Where does it go?

Well Drake it picks the keyword you entered and gives you 10 different suggestions (if they exist) for each letter of the alphabet. In my case it gives me a maximum of 260 suggestions.

It goes where you first call the function that scrapes google suggestion tool.

Pretty cool I think!

Let me add that my PHP is just crap. I'm sure someone can make it even better.


Cheers
 
For the script kiddies in the room (Me) What does that do?

Where does it go?

Takes your keyword and adds an A to the end so you get more suggestions.
Then adds B, then C, through Z.

Keyword: Big Booty
Original Result
84181396.gif


Script adds an A
Keyword: Big Booty A
Result
bba.gif


Script adds a B
Keyword: Big Booty B
Result
bbbh.gif




Pretty good idea for this script.
 
It's like Geek Poker in here. "I'll see your google suggest script and I'll raise it with a suggest script that does alphabetical variations!"

Anyone else gonna up the ante? :D
 
I have used this and what would be even cooler is if it did it like

Keyword Aa
Keyword Ab
Keyword Ac

etc...
Doing this you get 26*26 more variations and get to dig deeper.
 
I don't know I just use the google adword tool to find my relevant keywords. I know only basic php anyhow. Good Sharing
 
I have used this and what would be even cooler is if it did it like

Keyword Aa
Keyword Ab
Keyword Ac

etc...
Doing this you get 26*26 more variations and get to dig deeper.

PHP:
$abc = $abcd = array(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,'');
foreach ($abc as $outer) {    
	foreach ($abcd as $inner) {
		gsscrape($palav . ' ' . $outer . $inner);  
	}
}

That's going to do like 626 queries to Google - prolly get you banned.
 
Status
Not open for further replies.