从Google搜索结果中提取数据

I want to make program that extracts search results given by Google and save them into a text file.

For Example:

In this picture I want to save the data "New York ,NY,USA Thursday 11:0 PM Cloudy 13 C Precipitation:36% Humidity:90% Wind 8 KM/h" in a text file

enter image description here

Similarly, in this picture I want to save "1.8m" in a text file.

enter image description here

So, I would like to ask that is it even possible? if yes then how?

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 . The data i need is in the XHR response /URL which i cant seem to get. Anyone has any other ideas of how to do this or it is impossible?.

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);

You can use the Google Knowledge Graph API

https://developers.google.com/knowledge-graph/

you need to create a API key for that