GoogleWebSearchService
Namespace: Wisej.AI.Services
Assembly: Wisej.AI
Represents a web search service using Google's Custom Search API.
- C#
- VB.NET
public class GoogleWebSearchService : WebSearchServiceBase
Public Class GoogleWebSearchService
Inherits WebSearchServiceBase
This class extends the WebSearchServiceBase to provide functionality for performing web searches using Google's Custom Search API.
Constructors
GoogleWebSearchService(engineID, url)
Initializes a new instance of the GoogleWebSearchService class.
| Name | Type | Description |
|---|---|---|
| engineID | String | The unique identifier for the search engine. |
| url | String | The base URL for the Google Custom Search API. Default is "https://www.googleapis.com/customsearch/v1". |
Properties
Authentication
String: Gets the authentication method for the service. (Default: "api-key")
This property returns null as authentication is handled via API keys in the request URL.
Methods
SearchAsync(query)
Performs an asynchronous web search using the specified query.
| Parameter | Type | Description |
|---|---|---|
| query | String | The search query string. |
Returns: Task<String>. A task that represents the asynchronous operation. The task result contains the search results as a formatted string.
This method sends a request to the Google Custom Search API and processes the response to extract and format the search results.
var service = new GoogleWebSearchService("your-engine-id");
string results = await service.SearchAsync("example query");
Console.WriteLine(results);
Implements
| Name | Description |
|---|---|
| IWebSearchService | Represents a service for performing web searches. |