how to get google custom search result in json array

10,228

If you want a custom search result. Please read Custom Search Engine (free) of Google at:

Create custom search engine

And go to link to create your custom search:

https://cse.google.com/cse/

Or

You should go to:

Google search API

Click to link: Try this API in APIs Explorer

Insert your parameter:

  • "https://www.googleapis.com/customsearch/v1?"
    • "q=" + keyword (example: "Paris+Hilton")
    • "&cx=" + cx code of your CSE
    • "&key=" + your authorised API key [In link API project, click: A project is needed to enable APIs + Create project, then go to 'APIs & auth' and activate in 'Custom Search API']
    • "num=" + Number of search results to return (integer)

Press Execute to show a result with format JSON.

Share:
10,228
Nisarg
Author by

Nisarg

Updated on June 09, 2022

Comments

  • Nisarg
    Nisarg about 2 years

    I want to get google search results as json arrays in google latest custom search.

    How to implement the code.

    For Example :

     {
        "responseData": {` `
            "results": [
                {
          ` `          "GsearchResultClass ": "GwebSearch",
                    "unescapedUrl": "http:/ / en.wikipedia.org/wiki/Paris_Hilton",
                    "url"   : "http    ://    en.wikipedi a.org/wiki/Paris_Hilton",
                    "visibleUrl  "  : "en.wikipedia .org",
                    "cacheUrl    "    : "http://www.google.com/search?q=cache:TwrPfhd22hYJ:en.wikipedia.org",
                    "title": "<   b>Paris Hilton</b   > - Wikipedia, the free encyclopedia",
                    "titleNoFormatting": "Paris Hilton - Wikipedia, the free encyclopedia",
                    "content": "[1] In 2006, she released her debut album..."
                },
                {
                    "GsearchResultClass": "GwebSearch",
                    "unescapedUrl": "http://`   `www.imdb.com/name/nm0385296/",
                    "url": "http://`    `www.imdb.com/name/nm0385296/",
                    "visibleUrl":     "www.imdb.com",
                    "cacheUrl":      "http://www.google.com/search?q=cache:1i34KkqnsooJ:www.imdb.com",
                    "title": "<b>    Paris Hilton</b>",
                    "titleNoFormatting": "Paris Hilton",
                    "content": "    Self: Zoolander. Socialite <b>Paris Hilton</b>..."
                }
            ]
    
  • Admin
    Admin almost 8 years
    I got the result. But there is only showing few results. How to increase the showing counts of search result.
  • Ave
    Ave almost 8 years
    At num fields in console.developers.google.com/apis/api/customsearch/overview will return the number of search results. Please increase this values to get number result from your want.