我该怎么做与谷歌自定义搜索API用于.NET搜索? [英] How can I do a search with Google Custom Search API for .NET?

查看:218
本文介绍了我该怎么做与谷歌自定义搜索API用于.NET搜索?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现谷歌API客户端库.NET ,但由于缺乏文档我有一个很难有时间去弄明白。

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, by doing a custom search, and I have looked among other, at the following namespace:

Google.Apis.Customsearch.v1.Data.Query

我试图创建一个查询对象,并填写SearchTerms,但如何从该查询提取结果?

I have tried to create a query object and fill out SearchTerms, but how can I fetch results from that query?

推荐答案

看的参考
使用code从谷歌API-dotnet-客户

CustomsearchService svc = new CustomsearchService();

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

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<Search>(fileStream);
}

你也可以读出 Web客户端的流的Htt prequest ,如你所愿

这篇关于我该怎么做与谷歌自定义搜索API用于.NET搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆