Documentation
¶
Index ¶
- Variables
- func GoogleSearchResultsToJSON(results []*GoogleSearchResult) (string, error)
- type ErrorCallback
- type GoogleSearchClient
- type GoogleSearchResult
- type HTMLCallback
- type HTMLElement
- type Request
- type RequestCallback
- type ResponseCallback
- type Scraper
- type SearchClientConfig
- type Website
- type WikipediaClient
- type WikipediaParseResult
- type WikipediaQuerySearchResult
- type WikipediaQuerySummary
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Unique User-Agent header value for this client, see // https://en.wikipedia.org/api/rest_v1/#/ for more information. UserAgent = "CSXL/Solus/1.0.0" )
Functions ¶
func GoogleSearchResultsToJSON ¶
func GoogleSearchResultsToJSON(results []*GoogleSearchResult) (string, error)
Types ¶
type ErrorCallback ¶
type ErrorCallback = colly.ErrorCallback
type GoogleSearchClient ¶
type GoogleSearchClient struct {
// contains filtered or unexported fields
}
func NewGoogleSearchClient ¶
func (*GoogleSearchClient) GetBasePath ¶
func (gsc *GoogleSearchClient) GetBasePath() string
GetBasePath returns the base path of the GoogleSearchClient's HTTP client
func (*GoogleSearchClient) Search ¶
func (gsc *GoogleSearchClient) Search(query string) ([]*GoogleSearchResult, error)
func (*GoogleSearchClient) SetBasePath ¶
func (gsc *GoogleSearchClient) SetBasePath(basePath string)
SetBasePath sets the base path of the GoogleSearchClient's HTTP client
This is useful for unit testing.
type GoogleSearchResult ¶
type HTMLCallback ¶
type HTMLCallback = colly.HTMLCallback
type HTMLElement ¶
type HTMLElement = colly.HTMLElement
type RequestCallback ¶
type RequestCallback = colly.RequestCallback
type ResponseCallback ¶
type ResponseCallback = colly.ResponseCallback
type Scraper ¶
type Scraper struct {
// contains filtered or unexported fields
}
Scraper wraps the Colly scraper
func NewScraperWithCache ¶
NewScraperWithCache creates a new Scraper with a cache directory
type SearchClientConfig ¶
func NewSearchClientConfig ¶
func NewSearchClientConfig(googleSearchAPIKey string, googleSearchEngineID string) *SearchClientConfig
func (*SearchClientConfig) GetGoogleSearchAPIKey ¶
func (sc *SearchClientConfig) GetGoogleSearchAPIKey() string
func (*SearchClientConfig) GetGoogleSearchEngineID ¶
func (sc *SearchClientConfig) GetGoogleSearchEngineID() string
type Website ¶
type Website struct { Title string URL string Links []string MIME string HTMLContent string TextContent string }
func (*Website) GetHTMLContent ¶
func (*Website) GetTextContent ¶
type WikipediaClient ¶
type WikipediaClient struct { UserAgent string // contains filtered or unexported fields }
func NewWikipediaClient ¶
func NewWikipediaClient(ctx context.Context) (*WikipediaClient, error)
func (*WikipediaClient) GetPage ¶
func (c *WikipediaClient) GetPage(pageTitle string) (string, error)
func (*WikipediaClient) GetPageSummary ¶
func (c *WikipediaClient) GetPageSummary(pageTitle string) (string, error)
GetPageSummary returns the summary of a Wikipedia page. See https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bextracts for more information.
func (*WikipediaClient) Search ¶
func (c *WikipediaClient) Search(query string) ([]WikipediaQuerySearchResult, error)
Search performs a search on Wikipedia and returns a list of results. See https://en.wikipedia.org/w/api.php?action=help&modules=query%2Bsearch for more information.
type WikipediaParseResult ¶
type WikipediaParseResult struct {
Data string `json:"*"`
}
type WikipediaQuerySearchResult ¶
type WikipediaQuerySearchResult struct { Title string `json:"title"` Url string `json:"url"` PageID int `json:"pageid"` Size int `json:"size"` // A snippet includes html higlighting matching text on the page from the search query. // Example: // <span class=\"searchmatch\">Computing</span> is any goal-oriented activity requiring, benefiting from... Snippet string `json:"snippet"` }
type WikipediaQuerySummary ¶
Click to show internal directories.
Click to hide internal directories.