IT.COM

I need number of search results for multiple Google inquiries

Spaceship Spaceship
Watch
Greetings,
I hope somebody can help me.

Let's say I make a search and search for the word "London". Google says 730.000.000 results found. I write down. For "Bristol" 97.900.000 and for "Isle of man" 8.390.000 results. I write down.

London 730.000.000
Bristol 97.900.000
"Isle of man" 8.390.000

The problem is I can't keep doing this manually. I have very long lists. What should I do?
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Hmm... well you could create a custom script that retrieves all these queries from the google api. Basically you would need a list of places, and then a google api script. For each place you could loop through and query google and get the amount of results.

I don't have time to write you a lil script now, maybe someone else can :)
Until then you may also want to try www.twerq.com where you can do multiple searches at the same time, and it brings them up in different tabs. ie you could search London++Bristol++Isle Of Man and it would bring up 3 different tabs with the results nd info etc, just a cool lil site i found
 
0
•••
I don't know if Google will block your server/host/IP or not from this, but you could try it:

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
•••
They do want people using the API, but if this is only for personal research then i don't see why they would be bothered about it.
 
0
•••
Hello Dan,
Your code works perfect. Thank you very much. I figured that I can do an exact phrase seach by just adding quotation marks like you do when you make a search at google. The output is not each on a line but I can figure ways around.

I just hope I don't get banned. This thing is such a great help. Some NP$ is coming.
 
0
•••
I forgot I was going to make a text file instead of just outputting it to the browser. Change "\n" to "<br />" for each one to be on a new line.
 
0
•••
Thank you Dan. It works per line now. This is just such a great help for me. I can't thank you enough. Much appreciated.

All I do now is to edit the uploaded text file and then I simply click on the php file and thats all I do. I'm extremely happy with this.
 
0
•••
I know this thread finished a while ago, but I just found it and would really like to get the php working.

Marcel, did you need to change the code at all to get it working? It doesn't make sense to me as I don't know php, but I pasted it into notepad, saved it as a .php file, uploaded it, but it doesn't work -- I just get a blank page when I load the page. (I also changed the .txt bit to the txt file containing the words I want to query.)

Thanks!
Andy
 
0
•••
0
•••
Atoklas, did you change this "path/to/your/list/of/words/to/search/for.txt" to the actuall path to your text file?
 
0
•••
Hi Chicker,

I did change it, though I'm not sure if I changed it correctly -- I changed it to the url where the text file is located -- http://www.geocities.com/avatar11235/cars.txt.

I started a thread about this on phpfreaks.com, because I know nothing about php and couldn't get it working. No one over there has figured out why it's not working for me yet though.
 
0
•••
PHP:
<?php

$file = file('http://www.geocities.com/avatar11235/cars.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] . "<br />";
}
echo $results;

?>
That works fine for me. If it doesn't work for you, it's your host.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back