Excluding a list of urls or sites in Custom Search API

196 Views Asked by At

Excluding a list of urls in Custom Search API

Its good to be here and I hope I finally arrive at a solution after reading blogs, articles, community support answers and also Stackoverflows.

I'm trying to create a web application that aggregates result from Google using the Custom Search API.

Using the normal Google Search everyone uses everyday and all times, I am able to get what I found using this

Example: ​site:.com/ bla bla -site:example1.com -site:example2.com -site:example3.com -site:example4.com or -site:example5.com

or site:.com/ bla bla -example1.com -example2.com -example3.com -example4.com or -example5.com

or site:.com/ bla bla -example1 -example2 -example3 -example4 or -example5

Anytime I do this, I hit a limit of 32 words per search query. Fine, no problem.

I want to replicate this using the Custom Search API https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list

I hope to find a way to do the same thing but the API doesn't seem to do the same thing the normal Google Search does perfect albeit the words limit in place.

I'm using Postman to do all sort of testing but some urls I excuded are repeated or appearing in the results.

I've passed -site*** pattern in the following parameters q excludeTerms siteSearch with the exclude "e" or include "i" enum either one at a time or all together at once using different combinations but I can't succeed.

I found another pattern -inurl but it is also not ineffective in the API.

I would appreciate a lot help.

I did some Google Search before like

https://www.google.com/search?q=custom+search+api+exclude+sites+and+urls&oq=custom+search+api+exclude+sites+and+urls&aqs=chrome..69i57j33i160l2.17909j0j7&sourceid=chrome&ie=UTF-8

But I've not been successful so far.

1

There are 1 best solutions below

0
Rafaël Moreno Steenwinckel On

The solution is to use the /siterestrict url...

https://customsearch.googleapis.com/customsearch/v1/siterestrict