简体   繁体   English

适用于C#的Google Search API

[英]Google Search API for C#

Now that Google's discontinued their SOAP API, what can I use to search from C# code? 现在谷歌停止使用他们的SOAP API,我可以使用什么来搜索C#代码?

I know they have a Javascript AJAX API – I've implemented it and it works – but I just need to do the same thing but from the backend code. 我知道他们有一个Javascript AJAX API - 我实现了它并且它可以工作 - 但我只需要从后端代码执行相同的操作。

This is a piece of code, just for the record: 这是一段代码,仅供记录:

var searchTerm = "ABCD";
using (var web = new WebClient())
{
    web.Headers.Add("Referrer", "http://your-website-here/");
    var result = web.DownloadString(String.Format(
           "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q={0}&key=your-key-here", 
           searchTerm));
    Console.WriteLine(result);
}

The AJAX API has a RESTful interface. AJAX API具有RESTful接口。 Have a look here in the section titled "Flash and other Non-Javascript Environments" 看看这里的标题为“Flash和其他非JavaScript环境”

For Flash developers, and those developers that have a need to access the Web Search API from other Non-Javascript environments, the API exposes a simple RESTful interface. 对于Flash开发人员以及那些需要从其他非Javascript环境访问Web Search API的开发人员,API会公开一个简单的RESTful接口。 In all cases, the method supported is GET and the response format is a JSON encoded result set with embedded status codes. 在所有情况下,支持的方法是GET,响应格式是带有嵌入状态代码的JSON编码结果集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM