Avatar of Jerry L
Jerry L
Flag for United States of America asked on

PHP Script: Input Multiple Search Queries to Google Search Engine

Can someone help me writh some PHP code to do the following:

1. Submit multiple search queries (up to 100) to Google and pair the search string with the number of results found. I then want to save these paired results in a .csv file in a two column format. There will need to be a delay of 1 or 2 seconds between query submisisons to avoid incurring a spamming penalty.

3. Perhaps the results can be simply displayed in two columns in a browser window/tab which I can then copy and paste into a text file.  This will avoid the obvious problem of having the script trying to wrie to a file on the hard drive.

4. If a Database is needed we would have to do this as a Wordpress plugin.

5. It may be necessary to display the Google search output as either,
a) separate frames in one browser window, or
b) separate tabs
and then parse the source.

6. Perhaps the parsing can be done directly from the browser window?

7. Google displays the following text (from source code) which includes the number I'm looking to associate with the search string:  

           Results <b>1</b> - <b>10</b> of about <b>173,000</b>

EXAMPLE INPUT: ( single column of strings copied from Excel )
string one
string two
"string three"
"string four"

Column One      Column Two
string one              173,000
string two                     123
string three                2,345          < Notice, no quotes needed here
string four                13,101

Web DevelopmentWeb ApplicationsPHP

Avatar of undefined
Last Comment

8/22/2022 - Mon
Ray Paseur

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jerry L

I believe you are correct, Ray. Thanks for pointing that out.
Jerry L

I had not considered using the Google API when requesting a PHP solution. The solution by Ray was not "complete" since it doesn't solve the problem. But it does serve as a useful PAQ in case other readers explore the same issue.
Ray Paseur

Thanks for the points.  I've scraped screens before and everything works fine until it breaks without notice.  With the API approach, you usually get plenty of notice when a new API is available - makes for more seamless testing and evolution to the new interface.  Best regards, ~Ray
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy

i realize the question is closed but for what you are doing have you considered advanced web rankings?

they make an entire java-based package the gets rankings from the search engines (something they refuse to supply via API).