Skip to content

Instantly share code, notes, and snippets.

@thomasrayner
Last active September 2, 2016 19:10
Show Gist options
  • Save thomasrayner/690844751c1fe5f1fca2169237dc66f8 to your computer and use it in GitHub Desktop.
Save thomasrayner/690844751c1fe5f1fca2169237dc66f8 to your computer and use it in GitHub Desktop.
function Get-SearchResults {
[CmdletBinding()]
param(
[Parameter(Mandatory,Position=0)]
[string]$SearchTerms
)
$searchURL = "http://www.bing.com/search?q=$([System.Web.HttpUtility]::UrlEncode($searchTerms))"
$searchResults = Invoke-WebRequest $searchURL
$searchResults.links | ? { $_.href -match 'http' } | select innertext,href -first 10
}
#example
Get-SearchResults -SearchTerms 'two bears slow dancing'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment