public Search ( string start, string pageSize ) : List |
||
start | string | Index of where in the total result to return results. |
pageSize | string | Number of results to return. |
return | List |
public virtual List<GoogleSiteSearchResult> Search(string start, string pageSize)
{
if (this._results.Count > 0)
{
this._results.Clear();
}
// Check whether or not a Google customer ID has been defined
if (string.IsNullOrEmpty(this._googleCXNumber))
{
throw new NullReferenceException("Google SiteSearch exception: No CX number have been defined. Make sure the key is added to 'Site config/Search settings'.");
}
string response = this.DoSearch(this.FormatQueryString(this._googleCXNumber, this._q, start, pageSize, this._site));
GoogleSiteSearchParserResult result = this.ParseResult(response);
if (result != null)
{
this.NextResultPageUrl = result.NextUrl;
this.PreviousResultPageUrl = result.PreviousUrl;
this.NumberOfHits = result.Hits;
this._results = result.Result;
}
return this._results;
}
public static XPathNodeIterator Search(string query, int pageSize, int pageNumber, string site) { GoogleSiteSearch search = new GoogleSiteSearch(query, site); List<GoogleSiteSearchResult> results = search.Search(pageNumber.ToString(), pageSize.ToString()); XmlDocument document = GoogleSiteSearchUtil.GoogleSiteSearchToXmlDocument(search, results); XPathNavigator navigator = document.FirstChild.CreateNavigator(); return navigator.Select("/"); }