How can I do a search with Google Custom Search API for .NET?

前端 未结 5 891
执笔经年
执笔经年 2021-01-01 00:49

I just discovered the Google APIs Client Library for .NET, but because of lack of documentation I have a hard time to figure it out.

I am trying to do a simple test,

5条回答
  •  礼貌的吻别
    2021-01-01 01:40

    look at API Reference using code from google-api-dotnet-client

    CustomsearchService svc = new CustomsearchService();
    
    string json = File.ReadAllText("jsonfile",Encoding.UTF8);
    Search googleRes = null;
    ISerializer des = new NewtonsoftJsonSerializer();
    googleRes = des.Deserialize(json);
    

    or

    CustomsearchService svc = new CustomsearchService();
    
    Search googleRes = null;
    ISerializer des = new NewtonsoftJsonSerializer();
    using (var fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    {
        googleRes = des.Deserialize(fileStream);
    }
    

    with the stream you can also read off of webClient or HttpRequest, as you wish

提交回复
热议问题