Extracting a image from a WebBrowser Control

喜欢而已 提交于 2019-12-11 15:09:26

问题


My aim is to extract an image from a loaded webbrowser control.

// get the image link from the image element ID.
string imageLink = wbVideos.Document.GetElementById("sbvdcapimg").GetAttribute("src").ToString();

//Download the image into a bitmap
Bitmap image = new Bitmap(new System.IO.MemoryStream(new System.Net.WebClient().DownloadData(imageLink)));

so the code works for most pictures, but i receive me a format error when i use it with the link below.

The error is thrown when i parse this link into my code: "http://www.swagbucks.com/?cmd=cp-get-captcha-image&ctype=1&tai=478817685&sid=0.4015013770493371"

(Please Note to view the image you need to login!)

Notice how the image does not end in a extension, this is most likely causing the error.

Example of the extracted link:

so, my question, how can i make my code accept this link as a valid image file?

来源:https://stackoverflow.com/questions/20841872/extracting-a-image-from-a-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!