So I have a WebBrowser control that loads a set webpage and then I get all of the HTMLElements using GetElementsByTagName() with the <img> tag.
I would like to get a particular HTMLElement (see code below) and convert it into an image.
I've seen some answers already but they involve a seperate web request, which I can't do as the area the image is stored is protected, giving me a 403 (Access Denied) error.
I was thinking of making a new web browser control and navigating to the address, but I'm not sure it would work unless webbrowser controls share cookies.
Does anyone know of a way to directly convert the element into an image?
Here is the code I have already.
HtmlDocument doc = webBrowser1.Document;
HtmlElementCollection col2 = doc.GetElementsByTagName("img");
coll.Clear();
foreach (HtmlElement elImg in col2)
{
if (elImg.OuterHtml.ToLower().Contains("/sites/mysite/_layouts/15/userphoto.aspx"))
{
richTextBox1.Text = "Found Element";
// Found the HTML Element in element 2
}
//coll.Add(elImg.OuterHtml);
//pictureBox1.Image = ???
}
label5.Text = "Found " + coll.Count + " img elements";
Aucun commentaire:
Enregistrer un commentaire