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.
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.
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
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&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
Can anyone kindly assist in regards to this problem?