I have an Internet Explorer automation script in c#, it works ok but I want to access a captcha image the captcha link returns a refreshed image every time it is visited, and since the browser has already visited it once visiting it again would mess things up, so I tried to find the image in the browsers cache on the disk with the following code
tempDir = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache).ToString();
System.Console.WriteLine(tempDir);
supstra = element.innerHTML.ToString().Substring(element.innerHTML.ToString().IndexOf("/sorry/image?id="), element.innerHTML.ToString().Length - element.innerHTML.ToString().IndexOf("/sorry/image?id="));
Console.WriteLine("http://www.goolge.com/sorry/image?id=" + element.innerHTML.ToString().Substring(element.innerHTML.ToString().IndexOf("/sorry/image?id="), supstra.IndexOf("&hl=")));
captchas = client.Decode(tempDir + "\\" + element.innerHTML.ToString().Substring(element.innerHTML.ToString().IndexOf("/sorry/image?id=") + 7, supstra.IndexOf("&hl=")).Replace("amp;", "") + "=en", 0);
The image however in the cache directory is not an image but a command or something with the name image?id=....
and all it does is revisit and get new image. What do I have to do it seems is to somehow access the image the browser is showing, which might be only in the memory, how can I do that?
See this thread here on Accessing IE cache in C#.
Specifically, from the question:
And the answer (emphasis mine):
In the past when I've had to do something similar, I force the web browser (IE in this case) to use something like Fiddler2 as a proxy. In Fiddler2, I can then intercept the image requests for a particular URL and use C# to save them to disk in a known location. The automation program can then grab them from there.