0

I want to get the data that is shown in the highlighted Red box and store it in a file. The data is in the AJAX call as highlighted by the red arrow.

So i was wondering is it possible to get that data? If yes then how?

enter image description here

EDIT : I tried the following code given below.

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 .

var xhr = new XMLHttpRequest();
xhr.responseType = 'text';
xhr.open('GET', 'https://www.google.com.pk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=real+madrid', true);
xhr.onload = function () {
  console.log(xhr.response);
console.log(xhr.responseURL);
};
xhr.send(null);
Hashir Tariq
  • 11
  • 10
  • you can create a extension for that. – Sainesh Mamgain Feb 16 '17 at 11:38
  • Where do I start if I want to make an extension?. i'm sorry if i sound like a noob but i'm new to this . – Hashir Tariq Feb 16 '17 at 11:40
  • I think it is not the good idea. Do you want to get live soccer results or only last results? Also you can check it http://stackoverflow.com/questions/14256826/football-soccer-data-sources-apis – Teymur Mardaliyer Lennon Feb 16 '17 at 12:22
  • Well i want to implement an application which will enable users to search google without internet .They will enter the query which will goto the server which would run the script to fetch the required data and display it back at the app. So do you think is it possible? The app will only display the data given by google it self like in the picture given below. – Hashir Tariq Feb 16 '17 at 12:28
  • If you want to make an application like that first of all you will have to maintain a local Database because as you said this app will work without internet. `They will enter the query which will goto the server which would run the script to fetch the required data and display it back at the app.` For this user will need Internet. – Sainesh Mamgain Feb 16 '17 at 13:01
  • well i will be using Twilio API to communicate between my app and the server via SMS so i think internet access wont be required, no? – Hashir Tariq Feb 16 '17 at 13:03
  • Also google uses javascript to render the page content. so you will have to send request which tells google that javascript is disabled and it will return HTML content. Then you can extract your results from that HTML. – Sainesh Mamgain Feb 16 '17 at 13:05
  • If you are using api then its fine. But still you will have to manage the javascript part otherwise all you will get is a javascript code in response. – Sainesh Mamgain Feb 16 '17 at 13:08
  • So what API should i use to fetch the XHR data returned by google on a particular query? – Hashir Tariq Feb 16 '17 at 13:10
  • 1
    You can use curl for that in php. Review this answer http://stackoverflow.com/a/2559456/4094987 – ziishaned Feb 21 '17 at 02:55

0 Answers0