So i am sending a httpwebrequest to a particular website and i need an image from that website but this image loads 3-5 seconds after the the request is complete so the source does not contain the image, i want to make some kind of a delay so i can get the response a few seconds later, this is my code:
HttpWebRequest req1 = (HttpWebRequest)WebRequest.Create("url");
using(var httpResponse = req1.GetResponse())
{
using (var ResponseStream = httpResponse.GetResponseStream())
{
if (ResponseStream != null)
{
using (StreamReader sr = new StreamReader(ResponseStream))
{
string response = sr.ReadToEnd();
var doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(ResponseStream);
foreach(HtmlNode node in doc.DocumentNode.SelectNodes("src"))//it's not working because the source does not contain the image
{
pictureBox1.ImageLocation = node.ToString();
}
}
}
}
}
What is likely happening is that the page is loaded then a Javascript event fires and makes a separate call to the server to load the image. Delaying your HTTP request will not help you achieve what you desire.
I would suggest
If you provide a link to the page you’re talking about, myself or others might be able to clarify further.