google-search-results-dotnet 1.5.0

Search Results via SERP API. Hash, JSON, and HTML format supported for Google, Bing, Baidu, Yandex, Ebay, Google Product and more...

Install-Package google-search-results-dotnet -Version 1.5.0
dotnet add package google-search-results-dotnet --version 1.5.0
<PackageReference Include="google-search-results-dotnet" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add google-search-results-dotnet --version 1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Google/Bing/Baidu Search Result in Dotnet / CSharp / .Net

Build Status
NuGet version

This Dotnet package is meant to scrape and parse results from Google, Bing, Baidu, Yandex, Yahoo, Ebay and more using SerpApi.

This extension is in development. But the code can be re-use for production because the API is already stable.

The following services are provided:

SerpApi provides a script builder to get you started quickly.

Installation

To install the package.

dotnet add package google-search-results-dotnet --version 1.4.0

More commands available at https://www.nuget.org/packages/google-search-results-dotnet

Quick start

Let's run a search on Google.

using System;
using SerpApi;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Baidu
{
  class Program
  {

    static void Main(string[] args)
    {
      // secret api key from https://serpapi.com/dashboard
      String apiKey = "";

      // Localized search for Coffee shop in Austin Texas
      Hashtable ht = new Hashtable();
      ht.Add("location", "Austin, Texas, United States");
      ht.Add("q", "Coffee");
      ht.Add("hl", "en");
      ht.Add("google_domain", "google.com");

      try
      {
        BaiduSearchResultsClient client = new BaiduSearchResultsClient(ht, apiKey);

        Console.WriteLine("Search coffee in Austin, Texas on Google [1 credit]");
        JObject data = client.GetJson();
        Console.WriteLine("local coffee shop");
        JArray coffeeShops = (JArray)data["local_results"]["places"];
        foreach (JObject coffeeShop in coffeeShops)
        {
          Console.WriteLine("Found: " + coffeeShop["title"]);
        }
        Console.WriteLine("organic result coffee shop");
        coffeeShops = (JArray)data["organic_results"];
        foreach (JObject coffeeShop in coffeeShops)
        {
          Console.WriteLine("Found: " + coffeeShop["title"]);
        }

        string id = (string)((JObject)data["search_metadata"])["id"];
        Console.WriteLine("Search from the archive: " + id + ". [0 credit]");
        JObject archivedSearch = client.GetSearchArchiveJson(id);
        foreach (JObject coffeeShop in (JArray)archivedSearch["organic_results"])
        {
          Console.WriteLine("Found: " + coffeeShop["title"]);
        }

        //  Get account information
        Console.WriteLine("Account information: [0 credit]");
        JObject account = client.GetAccount();
        Dictionary<string, string> dictObj = account.ToObject<Dictionary<string, string>>();
        foreach (string key in dictObj.Keys)
        {
          Console.WriteLine(key + " = " + dictObj[key]);
        }

        // close socket
        client.Close()
      }
      catch (SerpApiClientException ex)
      {
        Console.WriteLine("Exception:");
        Console.WriteLine(ex.ToString());
      }
    }
  }
}

This example displays the top 3 coffee shop in Austin Texas found in the local_results.
Then it displays all 10 coffee shop found in the regular google search named: organic_results.

Bing search engine

client =  new BingSearchResultsClient(parameter, apiKey);

A full example is available here.
https://github.com/serpapi/google-search-results-dotnet/blob/master/example/bing/

Baidu search engine

client =  new BaiduSearchResultsClient(parameter, apiKey);

A full example is available here.
https://github.com/serpapi/google-search-results-dotnet/blob/master/example/baidu/

Yahoo search engine

client =  new YahooSearchResultsClient(parameter, apiKey);

test: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/yahoo_search_results_client_test.cs

Yandex search engine

client =  new YandexSearchResultsClient(parameter, apiKey);

test: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/yahoo_search_results_client_test.cs

Ebay search engine

client =  new EbaySearchResultsClient(parameter, apiKey);

test: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/ebay_search_results_client_test.cs

Test

This API is fully unit tested. The tests can be used as implementation examples.
https://github.com/serpapi/google-search-results-dotnet/tree/master/test

Changes log

1.5

  • Add support for Yandex, Ebay, Yahoo
1.4
  • Bug fix: Release Socket connection when requests finish.
    Because Dotnet does not release the ressource when the HTTP Client is closed.
  • Add Yahoo support: YahooSearchResultsClient
  • Create only one client for all the connection
1.3
  • Add bing and baidu support
  • Allow custom HTTP timeout using: setTimeoutSeconds
  • Fix exception class visibility and renamed to SerpApiClientException
1.2
  • Initial release matching SerpApi 1.2 internal API

TODO

  • [ ] Add advanced examples like: https://github.com/serpapi/google-search-results-ruby (wait for user feedback)

Google/Bing/Baidu Search Result in Dotnet / CSharp / .Net

Build Status
NuGet version

This Dotnet package is meant to scrape and parse results from Google, Bing, Baidu, Yandex, Yahoo, Ebay and more using SerpApi.

This extension is in development. But the code can be re-use for production because the API is already stable.

The following services are provided:

SerpApi provides a script builder to get you started quickly.

Installation

To install the package.

dotnet add package google-search-results-dotnet --version 1.4.0

More commands available at https://www.nuget.org/packages/google-search-results-dotnet

Quick start

Let's run a search on Google.

using System;
using SerpApi;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace Baidu
{
  class Program
  {

    static void Main(string[] args)
    {
      // secret api key from https://serpapi.com/dashboard
      String apiKey = "";

      // Localized search for Coffee shop in Austin Texas
      Hashtable ht = new Hashtable();
      ht.Add("location", "Austin, Texas, United States");
      ht.Add("q", "Coffee");
      ht.Add("hl", "en");
      ht.Add("google_domain", "google.com");

      try
      {
        BaiduSearchResultsClient client = new BaiduSearchResultsClient(ht, apiKey);

        Console.WriteLine("Search coffee in Austin, Texas on Google [1 credit]");
        JObject data = client.GetJson();
        Console.WriteLine("local coffee shop");
        JArray coffeeShops = (JArray)data["local_results"]["places"];
        foreach (JObject coffeeShop in coffeeShops)
        {
          Console.WriteLine("Found: " + coffeeShop["title"]);
        }
        Console.WriteLine("organic result coffee shop");
        coffeeShops = (JArray)data["organic_results"];
        foreach (JObject coffeeShop in coffeeShops)
        {
          Console.WriteLine("Found: " + coffeeShop["title"]);
        }

        string id = (string)((JObject)data["search_metadata"])["id"];
        Console.WriteLine("Search from the archive: " + id + ". [0 credit]");
        JObject archivedSearch = client.GetSearchArchiveJson(id);
        foreach (JObject coffeeShop in (JArray)archivedSearch["organic_results"])
        {
          Console.WriteLine("Found: " + coffeeShop["title"]);
        }

        //  Get account information
        Console.WriteLine("Account information: [0 credit]");
        JObject account = client.GetAccount();
        Dictionary<string, string> dictObj = account.ToObject<Dictionary<string, string>>();
        foreach (string key in dictObj.Keys)
        {
          Console.WriteLine(key + " = " + dictObj[key]);
        }

        // close socket
        client.Close()
      }
      catch (SerpApiClientException ex)
      {
        Console.WriteLine("Exception:");
        Console.WriteLine(ex.ToString());
      }
    }
  }
}

This example displays the top 3 coffee shop in Austin Texas found in the local_results.
Then it displays all 10 coffee shop found in the regular google search named: organic_results.

Bing search engine

client =  new BingSearchResultsClient(parameter, apiKey);

A full example is available here.
https://github.com/serpapi/google-search-results-dotnet/blob/master/example/bing/

Baidu search engine

client =  new BaiduSearchResultsClient(parameter, apiKey);

A full example is available here.
https://github.com/serpapi/google-search-results-dotnet/blob/master/example/baidu/

Yahoo search engine

client =  new YahooSearchResultsClient(parameter, apiKey);

test: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/yahoo_search_results_client_test.cs

Yandex search engine

client =  new YandexSearchResultsClient(parameter, apiKey);

test: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/yahoo_search_results_client_test.cs

Ebay search engine

client =  new EbaySearchResultsClient(parameter, apiKey);

test: https://github.com/serpapi/google-search-results-dotnet/blob/master/test/ebay_search_results_client_test.cs

Test

This API is fully unit tested. The tests can be used as implementation examples.
https://github.com/serpapi/google-search-results-dotnet/tree/master/test

Changes log

1.5

  • Add support for Yandex, Ebay, Yahoo
1.4
  • Bug fix: Release Socket connection when requests finish.
    Because Dotnet does not release the ressource when the HTTP Client is closed.
  • Add Yahoo support: YahooSearchResultsClient
  • Create only one client for all the connection
1.3
  • Add bing and baidu support
  • Allow custom HTTP timeout using: setTimeoutSeconds
  • Fix exception class visibility and renamed to SerpApiClientException
1.2
  • Initial release matching SerpApi 1.2 internal API

TODO

  • [ ] Add advanced examples like: https://github.com/serpapi/google-search-results-ruby (wait for user feedback)

Release Notes

README.md

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.5.0 133 5/12/2020
1.4.0 165 1/3/2020
1.3.1 440 8/26/2019
1.3.0 114 8/26/2019
1.2.0 152 7/8/2019