I'm trying to make a Google Images search in windows forms, and my code is returning null even though if I manually search the xPath it takes me to the images. I'm rather new to API's and NuGet packs so go easy on me LOL! The error specifically is 'Object reference not set to an instance of an object. But when I search the xPath it shows 48 results. Here is my code
private void searchButton_Click(object sender, EventArgs e)
{
string ImageQuery = titleTextBox.Text;
var htmlDocument = new HtmlWeb().Load("https://www.google.com/search?q=+" + ImageQuery + "&tbm=isch");
var imageNode = htmlDocument.DocumentNode.SelectSingleNode("//div[@class='bRMDJf islir']/img");
string imagePath = imageNode.Attributes["src"].Value;
var imageStream = HttpWebRequest.Create(imagePath).GetResponse().GetResponseStream();
this.optionOnePicture.Image = Image.FromStream(imageStream);
}