Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, you need to make sure you've generated your API Key and the CX. I am assuming you've done that already, otherwise you can do it at those locations:</p> <ul> <li><a href="https://code.google.com/apis/console" rel="nofollow">API Key</a> (you need to create a new browser key)</li> <li><a href="http://www.google.com/cse" rel="nofollow">CX</a> (you need to create a custom search engine)</li> </ul> <p>Once you have those, here is a simple console app that performs the search and dumps all the titles/links:</p> <pre><code>static void Main(string[] args) { WebClient webClient = new WebClient(); string apiKey = "YOUR KEY HERE"; string cx = "YOUR CX HERE"; string query = "YOUR SEARCH HERE"; string result = webClient.DownloadString(String.Format("https://www.googleapis.com/customsearch/v1?key={0}&amp;cx={1}&amp;q={2}&amp;alt=json", apiKey, cx, query)); JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary&lt;string, object&gt; collection = serializer.Deserialize&lt;Dictionary&lt;string, object&gt;&gt;(result); foreach (Dictionary&lt;string, object&gt; item in (IEnumerable)collection["items"]) { Console.WriteLine("Title: {0}", item["title"]); Console.WriteLine("Link: {0}", item["link"]); Console.WriteLine(); } } </code></pre> <p>As you can see, I'm using a generic JSON deserialization into a dictionary instead of being strongly-typed. This is for convenience purposes, since I don't want to create a class that implements the search results schema. With this approach, the payload is the nested set of key-value pairs. What interests you most is the items collection, which is the search result (first page, I presume). I am only accessing the "title" and "link" properties, but there are many more than you can either see from the documentation or inspect in the debugger.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload