google-search-results-dotnet 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package google-search-results-dotnet --version 1.2.0
NuGet\Install-Package google-search-results-dotnet -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="google-search-results-dotnet" Version="1.2.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.2.0
#r "nuget: google-search-results-dotnet, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install google-search-results-dotnet as a Cake Addin
#addin nuget:?package=google-search-results-dotnet&version=1.2.0

// Install google-search-results-dotnet as a Cake Tool
#tool nuget:?package=google-search-results-dotnet&version=1.2.0

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

Build Status

This Dotnet package is meant to scrape and parse Google or Bing or Baidu results 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:

Serp API provides a script builder to get you started quickly.

Feel free to fork this repository to add more backends.

Installation

Install dotnet I have only tested on OSX only.

Quick start

Search Google (default search engine)

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

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
    {
      GoogleSearchResultsClient client = new GoogleSearchResultsClient(ht, apiKey);
      JObject data = client.GetJson();

      Console.WriteLine("local coffee shop");
      JArray coffeeShops = (JArray)data["local_results"];
      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"]);
      }
    }
    catch (GoogleSearchResultsException 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.

Note: If you like to search with Baidu or Bing.

string engine = "bing"; # baidu
client =  new GoogleSearchResultsClient(ht, apiKey, engine);

TODO

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on google-search-results-dotnet:

Package Downloads
Promptflow.Tools The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

Prompt flow built-in tools

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 65,464 10/13/2020
1.5.0 1,578 5/12/2020
1.4.0 537 1/3/2020
1.3.1 901 8/26/2019
1.3.0 495 8/26/2019
1.2.0 557 7/8/2019

README.md