Sign in
Log inSign up

Is it poosible to write a script to get Google search results XHR response or XHR URL?

Hashir Tariq's photo
Hashir Tariq
·Feb 18, 2017

I want to extract the data given by google itself like in the image given below. http://i.imgur.com/cxqNtWP.jpg The data I want to get is the one in the Red box. The data is present in the XHR response which i have underlined. Now is it poosible to write a script to obtain this data or even the URL? So far I have tried this :

 var xhr = new XMLHttpRequest();
xhr.responseType = 'text';
xhr.open('GET', 'google.com.pk/webhp?sourceid=chrome-instan…, true);
xhr.onload = function () {
 // console.log(xhr.responseURL); // example.com/test
  console.log(xhr.response);
  console.log(xhr.responseURL);
 };
xhr.send(null);

The xhr.response gives the source code of the page which does not contain the data i want and the xhr.responseURL gives the URL of google itself https://www.google.com.pk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct