0
我需要一点帮助。下面的代码工作flawlesly当我搜索的是网页,但是当我想要搜索的图像使用Google CustomsearchService在网络上搜索图像
const string apiKey = "xxxx";
const string searchEngineId = "xxxx";
const string query = "apple";
var customSearchService = new CustomsearchService(new BaseClientService.Initializer { ApiKey = apiKey });
var listRequest = customSearchService.Cse.List(query);
listRequest.Cx = searchEngineId;
listRequest.Num = 1;
//listRequest.Fields = "items(image(contextLink,thumbnailLink),link)";
listRequest.SearchType = CseResource.ListRequest.SearchTypeEnum.Image;
listRequest.Start = 1;
var search = listRequest.Execute();
foreach (var result in search.Items)
{
Debug.WriteLine(string.Format("Title: {0}", result.Title));
Debug.WriteLine(string.Format("Link: {0}", result.Link));
}
search.Items
结果荷兰国际集团null
时SearchType
是Image
。