Get First Search Result from google
<p>I am currently attempting to use Powershell to scrape link pages from a specific site.  Have knocked up a variation of the current code but it is essential the same.</p>

<p>I am attempting to get the URL for the search google search result. I have added the below screenshot to explain what i am hoping to grab.</p>

<p><a href="https://i.stack.imgur.com/9Q0XC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Q0XC.png" alt="enter image description here"></a></p>

<p>I so far have the following code which is converting the text to a successful search and is working as expected.however when called with the Invoke-WebRequest i dont get any meaningful results. when using a browser with the link it works sucsessfully</p>

<pre><code>function Get-GoogleSEQueryString 
{
    param([string[]] $Query)

    Add-Type -AssemblyName System.Web # To get UrlEncode()
    $QueryString = ($Query | %{ [Web.HttpUtility]::UrlEncode($_)}) -join '+'

    # Return the query string
    $QueryString
}

$SearchString = "Requiem for an American Dream"
$QueryString = Get-GoogleSEQueryString $SearchString
$url = "http://www.google.com.au/?gfe_rd=cr&amp;ei=ZuzTV_v6B7Du8weC8qsY#q="+$QueryString+"+site:IMDB.com"

#(Invoke-WebRequest -Uri $url).links | Where-Object {$_.href -like "http*"}

$t = Invoke-WebRequest -uri $url
$t.AllElements | Where {$_.innerhtml -like '*=*'} |Sort { $_.InnerHtml.Length } | Out-GridView
</code></pre>

<p>Can anyone kindly assist in regards to this problem?</p>