public async System.Threading.Tasks.Task GoggleNoResultsReturnedAsync() { ISearchEngine google = new GoogleSearch(); var results = await google.GetSearchResultListAsync("asdasdsadadfdwefvtrvrtbwcvwregerge", 1); Assert.IsTrue(results.Count == 0); }
public async Task <IActionResult> GetAvailables() { //API Key const string apiKey = "AIzaSyCzUGfbgbzOPERSArlTI8kAjphhsIFVGXU"; //The custom search engine identifier const string searchEngineId = "012492674958042532303:q2ey6tmaaru"; const string query = "Discotecas de Trujillo"; var tmpList = new List <ItemModel>(); var result = new GoogleSearch { Key = apiKey, CX = searchEngineId }; result.SearchCompleted += (a, b) => { tmpList = b.Response.Items; }; result.Search(query); return(Json(tmpList)); }
public List <GoogleResult> GatherSearchResults(bool googleApiChoice) { var api = new GoogleSearch(); var eilishResults = new List <GoogleResult>(); var grandeResults = new List <GoogleResult>(); var mendesResults = new List <GoogleResult>(); if (googleApiChoice) { eilishResults = api.GetSearchResults("Billie Eilish - Therefore I am"); if (eilishResults.Count > 0) //Prevent multiple dialog boxes from appearing { grandeResults = api.GetSearchResults("Ariana Grande - Positions"); mendesResults = api.GetSearchResults("Shawn Mendes - Monster"); } } else { eilishResults = api.GetGoogleApiResults("Billie Eilish - Therefore I am"); grandeResults = api.GetGoogleApiResults("Ariana Grande - Positions"); mendesResults = api.GetGoogleApiResults("Shawn Mendes - Monster"); } MergedResults = eilishResults.Union(grandeResults).Union(mendesResults).ToList(); return(MergedResults); }
public async System.Threading.Tasks.Task GoggleFixedResultReturnedAsync() { ISearchEngine google = new GoogleSearch(); var results = await google.GetSearchResultListAsync("test", 1); Assert.IsTrue(results.Count == 1); }
public void TestGetJson() { search = new GoogleSearch(ht, apiKey); JObject data = search.GetJson(); JArray coffeeShops = (JArray)data["local_results"]["places"]; int counter = 0; foreach (JObject coffeeShop in coffeeShops) { Assert.IsNotNull(coffeeShop["title"]); counter++; } Assert.IsTrue(counter >= 1); coffeeShops = (JArray)data["organic_results"]; Assert.IsNotNull(coffeeShops); foreach (JObject coffeeShop in coffeeShops) { Console.WriteLine("Found: " + coffeeShop["title"]); Assert.IsNotNull(coffeeShop["title"]); } // Release socket connection search.Close(); }
public IEnumerable <GoogleSearchResult> Search(string term) { var gs = new GoogleSearch("016976589848602941170:e0rsagztt6w", key: "AIzaSyDx9z_1Y2x4EF6OQyiY1y2emRG8QHD2CTM"); //basic search return(gs.Search(term)); }
// Home Paage public IActionResult Index(string searchTerms, string targetURL, string numResults) { if (!string.IsNullOrEmpty(searchTerms)) { // Set the search filters GoogleFilter filters = new GoogleFilter(Convert.ToInt32(numResults)); // Object used to perform search queries and get parsed results GoogleSearch google = new GoogleSearch(filters); // Get results for query filtred by url List <WebResult> results = google.RunSearchQuery(searchTerms, targetURL); // A web exception was thrown if (results == null) { ViewData["WebError"] = "A web error has occured"; } // Pass data to view ViewData["Results"] = results; ViewData["ResultCount"] = results.Count; ViewData["TargetURL"] = targetURL; ViewData["NumResults"] = numResults; ViewData["Query"] = searchTerms; } return(View()); }
public void TestGoogleSearchResult() { var googleSearch = new GoogleSearch(_ => File.ReadAllText(System.Environment.CurrentDirectory + @"\Mock\mock.html")); var result = googleSearch.Search("online title search", "www.infotrack.com.au"); Assert.AreEqual("2", result); }
public void TestUserIpCse() { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 1, pageSize: 5, key: TestConfigs.Key, method: GoogleSearchMethod.CSE, userIp: "192.168.1.101"); var results = gs.Search("dam"); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count == 5); }
public void TestNoResults() { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 2, pageSize: 10, key: TestConfigs.Key); var results = gs.Search("dfhgjkdfhgdfjkbgjkerbgdfuibvefuibvuybruyfbruo"); Assert.IsFalse(gs.Options.ContainsKey("start")); Assert.IsFalse(results.Any()); }
public async Task MakeItemAsync(string item) { string response = ""; GoogleSearch gSearch = new GoogleSearch("007509064276126836146:56wy_xocjvk", "AIzaSyApvwKmpMqbImEEkQdLE7uPe5LdAxOrV9Q"); List <GoogleSearchResult> results = gSearch.Search(item); response = results.Last().ToString(); await Context.User.SendMessageAsync(response); }
public async Task<List<RemoteSearchResult>> Search(int[] siteNum, string searchTitle, DateTime? searchDate, CancellationToken cancellationToken) { var result = new List<RemoteSearchResult>(); if (siteNum == null || string.IsNullOrEmpty(searchTitle)) { return result; } var directURL = searchTitle.Replace(" ", "-", StringComparison.OrdinalIgnoreCase).ToLowerInvariant(); if (!directURL.Contains("/", StringComparison.OrdinalIgnoreCase)) { directURL = directURL.Replace("-", "/", 1, StringComparison.OrdinalIgnoreCase); } if (!int.TryParse(directURL.Split('/')[0], out _)) { directURL = directURL.Replace("/", "-", 1, StringComparison.OrdinalIgnoreCase); } else { directURL = directURL.Split('/')[1]; } directURL = Helper.GetSearchSearchURL(siteNum) + directURL; var searchResultsURLs = new List<string> { directURL, }; var searchResults = await GoogleSearch.GetSearchResults(searchTitle, siteNum, cancellationToken).ConfigureAwait(false); foreach (var searchResult in searchResults) { if (searchResult.Contains("/movies/", StringComparison.OrdinalIgnoreCase) && !searchResultsURLs.Contains(searchResult)) { searchResultsURLs.Add(searchResult); } } foreach (var url in searchResultsURLs) { var sceneURL = new Uri(url); var sceneID = new List<string> { Helper.Encode(sceneURL.AbsolutePath) }; if (searchDate.HasValue) { sceneID.Add(searchDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); } var searchResult = await Helper.GetSearchResultsFromUpdate(this, siteNum, sceneID.ToArray(), searchDate, cancellationToken).ConfigureAwait(false); if (searchResult.Any()) { result.AddRange(searchResult); } } return result; }
public async Task ValidateType() { var googleService = new GoogleSearch(); var term = ".net"; var result = await googleService.GetResultsAsync(term); Assert.AreEqual(result.GetType(), typeof(long)); }
public async Task ValidateEmpty() { var googleService = new GoogleSearch(); var term = ""; var result = await googleService.GetResultsAsync(term); // Empty term should give -1 as result Assert.AreEqual(result, -1); }
public void Fourth_search_result_contains_given_string() { const string searchString = "Selenium IDE export to C#"; const string expectedResults = "Selenium IDE"; var searchResults = GoogleSearch.SearchFor(searchString); var fourthSearchResult = searchResults.GetResultNo(4); Assert.IsTrue(fourthSearchResult.HeaderText.Contains(expectedResults), $"Actual text was: '{fourthSearchResult.HeaderText}' while we expected it to contain '{expectedResults}'"); }
public void HtmlEdit_SetText_Succeeds() { GoogleHomePage pgGHomePage = WebPage.Launch <GoogleHomePage>("http://www.google.com"); pgGHomePage.txtSearch.SetText("Coded UI Test Framework"); GoogleSearch pgSearch = WebPage.GetPage <GoogleSearch>(); UITestControlCollection col = pgSearch.divSearchResults.UnWrap().GetChildren(); //do something with collection pgSearch.Close(); }
public void TestSpecialCaseCse() { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 1, pageSize: 5, key: TestConfigs.Key); gs.Options.Add("fileType", "pdf"); var results = gs.Search("dam"); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count == 5); Assert.IsTrue(results.All(r => r.Url.Contains(".pdf"))); }
public void ChromeHomePageTest() { GoogleSearch googleSearch = new GoogleSearch(); googleSearch.TestTilePageSourcePageSourceLen(); googleSearch.searchTextTest("Selenium"); googleSearch.gmailLinkTest(); googleSearch.picLinkTest(); googleSearch.signInLinkTest(); googleSearch.browser.GetDriver().Quit(); }
public void TestGetHtml() { search = new GoogleSearch(ht, apiKey); string htmlContent = search.GetHtml(); Assert.IsNotNull(htmlContent); //Console.WriteLine(htmlContent); Assert.IsTrue(htmlContent.Contains("</body>")); // Release socket connection search.Close(); }
public void HtmlEdit_SetText_Succeeds() { GoogleHomePage pgGHomePage = BrowserWindowUnderTest.Launch <GoogleHomePage>("http://www.google.com"); pgGHomePage.txtSearch.Text = "Coded UI Test Framework"; GoogleSearch pgSearch = BrowserWindowUnderTest.GetBrowserWindow <GoogleSearch>(); // ReSharper disable once UnusedVariable UITestControlCollection col = pgSearch.divSearchResults.SourceControl.GetChildren(); //do something with collection pgSearch.Close(); }
private IList <ISearch> GetImplementedSearchEngines() { GoogleSearch google = new GoogleSearch(); BingSearch bing = new BingSearch(); IList <ISearch> engines = new List <ISearch>(); engines.Add(google); engines.Add(bing); return(engines); }
public async Task Google([Remainder] string query) { var results = await GoogleSearch.Search(query); var embed = new EmbedBuilder(); embed.WithTitle(results[0].Title); embed.WithDescription(results[0].Snippet); embed.Url = results[0].Link; await Context.Channel.SendMessageAsync("This was the first result: ", false, embed); }
public async Task GoogleTest() { ISearch _searchEngine; IList <ISearch> engines = new List <ISearch>(); _searchEngine = new GoogleSearch(); var result = await _searchEngine.TotalResults(".net"); Assert.IsNotNull(result); }
static void Main(string[] args) { GoogleSearch oGoogleSearch = new GoogleSearch(); BingSearch oBingSearch = new BingSearch(); Console.WriteLine("Type programming languages and press enter:"); ///GET DATA FROM INPUT string data = Console.ReadLine(); ///SEPARATING DATA FROM INPUT BY SPACE var toSearchList = data.Split(' '); long googleSearchResult = default(long); long bingSearchResult = default(long); List <Result> googleResultList = new List <Result>(); Result googleResult = new Result(); List <Result> bingResultList = new List <Result>(); Result bingResult = new Result(); foreach (var item in toSearchList) { ///SEARCH IN GOOGLE googleResult = oGoogleSearch.GetGoogleSearchList(item); googleSearchResult = googleResult.ErrorMessage != null ? default(int) : googleResult.GoogleAmount; googleResultList.Add(googleResult); ///SEARCH IN BING bingResult = oBingSearch.GetBingSearchList(item); bingSearchResult = bingResult.ErrorMessage != null ? default(int) : bingResult.BingAmount; bingResultList.Add(bingResult); Console.WriteLine($"{item}:\n\tGoogle: {googleSearchResult}\n\tMSN Search: {bingSearchResult}\n"); } string programmingLanguageGoogleWinner = googleResultList.FirstOrDefault(m => m.GoogleAmount == googleResultList.Max(x => x.GoogleAmount)).ProgrammingLanguage; string programmingLanguageBingWinner = bingResultList.FirstOrDefault(m => m.BingAmount == bingResultList.Max(x => x.BingAmount)).ProgrammingLanguage; Console.WriteLine($"Google winner: {programmingLanguageGoogleWinner}\n"); Console.WriteLine($"MSN winner: {programmingLanguageBingWinner}\n"); string totalWinnerSearch = googleResultList.Max(x => x.GoogleAmount) > bingResultList.Max(x => x.BingAmount) ? programmingLanguageGoogleWinner : programmingLanguageBingWinner; Console.WriteLine($"Total winner: {totalWinnerSearch}"); Console.WriteLine("Press enter to exit"); Console.ReadLine(); }
public void TestMethodSimpleXml() { try { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 2, pageSize: 20, method: GoogleSearchMethod.XML, key: TestConfigs.Key); var results = gs.Search("garbage"); Assert.IsTrue(false); // fail is exception not thrown } catch (Exception e) { Assert.AreEqual("The XML API is no longer available as it was only for Google Site Search", e.Message); } }
private async void button2_Click(object sender, EventArgs e) { textBox3.Clear(); var progress = new Progress <string>(update => textBox3.AppendText(update + Environment.NewLine)); var chromiumSettings = CompositionRoot.Resolve <IChromiumSettings>(); if (!string.IsNullOrEmpty(tbGoogleProxy.Text)) { chromiumSettings.Proxy = tbGoogleProxy.Text; } var googleSearch = new GoogleSearch(chromiumSettings: chromiumSettings, progressLog: progress); await googleSearch.RunScenario(queries : textBox6.Lines, pageCount : (int)udPageCount.Value); }
public void TestSimpleCse() { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 2, pageSize: 10, key: TestConfigs.Key, method: GoogleSearchMethod.CSE); Assert.IsFalse(gs.Options.ContainsKey("start")); var results = gs.Search("dam"); Assert.IsFalse(gs.Options.ContainsKey("start")); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count <= 20); Assert.IsTrue(results.Count > 10); results = gs.Search("dam", "Businesses"); Assert.IsTrue(results.Count == 2); }
public void TestMethodSimpleXml() { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 2, pageSize: 20, method: GoogleSearchMethod.XML); Assert.IsFalse(gs.Options.ContainsKey("start")); var results = gs.Search("garbage"); Assert.IsFalse(gs.Options.ContainsKey("start")); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count <= 40); Assert.IsTrue(results.Count > 30); results = gs.Search("dam", "Businesses"); Assert.IsTrue(results.Count == 2); }
public void TestLargeCse() { var gs = new GoogleSearch(TestConfigs.Cseid, maxPages: 200, pageSize: 10, key: TestConfigs.Key, method: GoogleSearchMethod.CSE); Assert.IsFalse(gs.Options.ContainsKey("start")); var results = gs.Search("the"); Assert.IsFalse(gs.Options.ContainsKey("start")); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Count == 100); gs.Options["start"] = "85"; // first results is 85th, so 16 results = gs.Search("the"); Assert.IsTrue(results.Count == 16); }
public void TestMethod1() { var gSearchPage = new GoogleSearch(driver); var gResultsearchpage = gSearchPage.NavigateResultPage(); var SelOrgPage = gResultsearchpage.gResultPage(); string ActualLogoName = SelOrgPage.getLogName(); string ExpectedLogName = "Projects"; Console.WriteLine("Actual " + ActualLogoName); Console.WriteLine("Expected " + ExpectedLogName); Assert.IsTrue(ActualLogoName.Equals(ExpectedLogName)); Thread.Sleep(5000); }
private static void Main() { var googleSearch = new GoogleSearch(); googleSearch.Start(); }
private void googleSearchToolStripMenuItem_Click(object sender, EventArgs e) { GoogleSearch g = new GoogleSearch(ActiveEditor.codebox.Text, Common.SearchMethod.Startinbrowser); }