Is there any google API to capture the highlighted search information?

3

Is there an API or something like that in which I can capture highlighted information from a google search? For example, when I search for "Bill Gates" some information about it appears in the right frame:

    
asked by anonymous 04.09.2016 / 19:18

1 answer

5

This table is called Knowledge Graph and you can find documentation here .

For example, when you make this request (you will need to enter your API key):

link

You will receive:

...
"itemListElement": [{
    "@type": "EntitySearchResult",
    "result": {
        "@id": "kg:/m/017nt",
        "name": "Bill Gates",
        "@type": [
            "Person",
            "Thing"
        ],
        "description": "Magnata",
        "image": {
            "contentUrl": "http://t0.gstatic.com/images?q=tbn:ANd9GcRXjfjE0L0XHKNqiGayo9stzrfNMkJs2wDxs36K1DStW1WqLi4p",
            "url": "https://en.wikipedia.org/wiki/Bill_Gates",
            "license": "http://creativecommons.org/licenses/by/2.0"
        },
        "detailedDescription": {
            "articleBody": "William Henry Gates III mais conhecido como Bill Gates, é um magnata, filantropo e autor norte-americano, que ficou conhecido por fundar junto com Paul Allen a Microsoft, a maior e mais conhecida empresa de software do mundo em termos de valor de mercado.\n",
            "url": "http://pt.wikipedia.org/wiki/Bill_Gates",
            "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
        },
        "url": "http://www.gatesnotes.com/"
    },
    "resultScore": 675.914368
}]
...

Google uses some Wikipedia information - as the link just below the description on Bill Gates suggests. Wikipedia uses MediaWiki software, which has a API for queries . It may also be interesting to consult the data there.

For example, by making the following request:

link

You will get:

{{Mais notas|data=outubro de 2014}}
{{Info/Biografia
|nome                =Bill Gates
|nome_completo       =William Henry Gates III
|conhecido_por       =ser fundador da [[Microsoft]]
|imagem              =Dts news bill gates wikipedia.JPG
|nascimento_local    =[[Seattle]], [[Condado de King (Washington)|King]], [[Washington]],<br /> {{USA}}
|residência          =[[Medina (Washington)|Medina]], King, Washington, <br />{{USAb}} Estados Unidos
|nacionalidade       =[[Estadunidenses|Norte-americano]]
|fortuna             ={{Increase}} [[Dólar dos Estados Unidos|US$]] 78.3 [[Bilhão|bilhões]] <small>(Agosto 2016)<ref name="net worth">{{cite web|title=#1 Bill Gates|url=http://www.forbes.com/profile/bill-gates/?list=billionaires|publisher=Forbes|accessdate=January 2, 2016}}</ref>
|legenda             =Bill Gates em [[Berlim]] (janeiro de 2013)
|data_nascimento     ={{nowrap|{{dni|lang=br|28|10|1955}}}}

etc...

From here, you have some options to extract the data, from using regex in this infobox in wikitext or modify the API request to return the already compiled HTML ( prop=text ), so you can use some HTML parser in php.

In addition to Wikipedia, Google uses other sources as well. In the case of Bill Gates, they included his fortune from the Forbes data. This magazine also has an API, and so on.

    
05.09.2016 / 12:01