G
G
GuitarFan2013-11-23 14:43:28
Google
GuitarFan, 2013-11-23 14:43:28

How to parse the number of results from a Google search using PHP

I need to read the number of results that Google will display for a certain word. So you need to do this many times (let's drive in about 5k words and count the number of results)
I tried to google google search api - I didn’t really understand anything, I didn’t find instructions on how to work with it. I'm newbie, worked mostly with PHP only.
Please tell me how can I do this...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladlen Grachev, 2013-11-23
@GuitarFan

Open google. Do a couple of requests. Look at the changes in the url, on the basis of which you draw conclusions about how the url is formed.
Next, you form a list of urls for all the necessary requests, go through these urls, use regular expressions to extract the number of results from the given data (displayed under the search form).
All this is implemented using standard PHP tools.
If necessary, you can complicate and improve the algorithm ad infinitum.

G
GuitarFan, 2013-11-23
@GuitarFan

The point is that when the code is executed:

function grab($site){	
  $data = file_get_contents($site);
  echo $data;
        if ($data) return $data; else return FALSE;

$site = https://www.google.ru/#newwindow=1&q=Vasya
The fact is that when $data is displayed, the main page is displayed, and not the page I need with search results for the keyword Vasya. Google does not just allow you to go to the page https://www.google.ru/#newwindow=1&q=Vasya from another page, as I understand it. The request is made somehow based on JS.

A
Alexander, 2013-11-24
@kryoz

Is it really worth reinventing the wheel?
http://stackoverflow.com/questions/4082966/google-web-search-api-deprecated-what-now
It says how to tie Google Custom Search engine to global search

F
frees2, 2014-01-01
@frees2

https://www.googleapis.com/freebase/v1/search?quer...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question