![]() |
VOOZH | about |
The CData Cmdlets for Google Search are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Google Search.
The Cmdlets are not only a PowerShell interface to Google Search, but also an SQL interface; this tutorial shows how to use both to retrieve Google Search results. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Google Search. To access Google Search results from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Google Search.
Once you have acquired the necessary connection properties, accessing Google Search results in PowerShell can be enabled in three steps.
To search with a Google custom search engine, you need to set the CustomSearchId and ApiKey connection properties.
To obtain the CustomSearchId property, sign into Google Custom Search Engine and create a new search engine.
To obtain the ApiKey property, you must enable the Custom Search API in the Google API Console.
Install the module:
Install-Module GoogleSearchCmdlets
Connect:
$googlesearch = Connect-GoogleSearch -CustomSearchId "$CustomSearchId" -ApiKey "$ApiKey"
Search for and retrieve data:
$searchterms = "WayneTech" $videosearch = Select-GoogleSearch -Connection $googlesearch -Table "VideoSearch" -Where "SearchTerms = `'$SearchTerms`'" $videosearch
You can also use the Invoke-GoogleSearch cmdlet to execute SQL commands:
$videosearch = Invoke-GoogleSearch -Connection $googlesearch -Query 'SELECT * FROM VideoSearch WHERE SearchTerms = @SearchTerms' -Params @{'@SearchTerms'='WayneTech'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Google Search\lib\System.Data.CData.GoogleSearch.dll")
Connect to Google Search:
$conn= New-Object System.Data.CData.GoogleSearch.GoogleSearchConnection("CustomSearchId=def456;ApiKey=abc123;")
$conn.Open()
Instantiate the GoogleSearchDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Title, ViewCount from VideoSearch"
$da= New-Object System.Data.CData.GoogleSearch.GoogleSearchDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.title $_.viewcount
}
Download a free trial of the Google Search Data Provider to get started:
Download NowLearn more:
👁 Google Search IconEasy-to-use Google search client enables .NET-based applications to easily search Google and filter search results.