Search code examples
javasearchgoogle-custom-search

Make results of google-CSE random


I'm creating a google search engine with the CSE of google. I'm trying to get one random result every time i search for a query. For example: When I search for the word "coffee" the engine returns one result, random from all the "coffee results".

Is there someone who can help me to make the result random?

Thanks!!


Solution

  • Number the results (i.e. store them in an array) and use the random number to pick a result (chosen_result = results_array[random_num];)

    If this doesn't suit your needs you will need to provide more information such as the programming language you're using for this.