Search code examples
google-custom-searchgoogle-apis-explorer

How to achieve dynamic site search using Custom Search Engine REST API


Requirement: From my web page user has the ability to add websites and fetch a collection of web pages having the input search term.

We have been using CSE V1 API to extract web pages based on a search term on the desired websites by making use of cref parameter. Since Google stopped supporting Link CSE feature (https://customsearch.googleblog.com/2017/02/refocusing-and-looking-forward-on.html), how do I implement the dynamic site search feature?

Thanks in Advance, Raghu


Solution

  • On further analysis, custom site search is possible with the siteSearch parameter. Ref: https://developers.google.com/custom-search/json-api/v1/reference/cse/list#siteSearch. This parameter accepts only one website as the value, so for multiple website searches, invoke the Google CSE API multiple times for each website.

    While creating the search engine, select the option "Search the entire web but emphasise included sites" so that you can hook websites while invoking the CSE API. To enable siteSearch parameter of API

    Hope it helps.
    -Raghu