LuanRT / google-this

A simple yet powerful module to retrieve organic search results and much more from Google.

Home Page:https://www.npmjs.com/package/googlethis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move to Google's private API (Image Search)

LuanRT opened this issue · comments

commented

It seems like the google website uses an API to fetch image search results, the data is a bit messy but it's way faster than parsing raw html, has more metadata, returns up to 100 images, and allows more request options.

Sample Code

This could be done by sending a post request to https://www.google.com/_/VisualFrontendUi/data/batchexecute with the following payload (form data):

"f.req" => [
    [
      [
        "HoAMBc",
        JSON.stringify([
          null, null, [
            2,null,529,5,396,
            [],[9429,9520],[194,194],
            false,null,null,9520
          ],
          null,null,null,null, null,null,null,null,
          null,null,null,null, null,null,null,null,
          null,null,null,null, null,null,null,null,
          null,[
            "query-goes-here",
            null,null,null, null,null,null,
            null,null,null, null,null,null,
            null,null,null, null,null,null,
            null,null, "lnms"
          ],
          null,null,null,
          null,null,null,
          null,null,[
            null, "CAE=", "GGwgAA==" // these are protobufs
          ],null,true
        ]),
        null, "generic"
      ]
    ]
]
"at" => `ABrGKkThP-sNRUU6e86GjhgSvs0k:${new Date().getTime()}` // random request id + timestamp