您的位置:首页 > 其它

获取图片的三种方法

2009-10-05 12:42 218 查看
第一种方法

HtmlElementCollection hc = webBrowser1.Document.GetElementsByTagName("img");
HtmlElement h0 = null;
foreach (HtmlElement h in hc)
{
if (h.OuterHtml.Contains("code.en.img.php"))
{
h0 = h;
MessageBox.Show(h.OuterHtml.ToString());
}

}

MessageBox.Show(h0.GetAttribute("src"));
string imgurl = h0.GetAttribute("src");
pictureBox1.ImageLocation = imgurl;

------------------------分割符---------------------------------
第二种方法
HtmlElement he = webBrowser1.Document.Images[10];
mshtml.IHTMLImgElement img = (mshtml.IHTMLImgElement)(he.DomElement);
string a = img.src;

------------------------分割符---------------------------------
第三种方法

HttpWebRequest hwr = (HttpWebRequest)HttpWebRequest.Create("http://www.doudou.com/code.en.img.php");

Bitmap bmp = new Bitmap(hwr.GetResponse().GetResponseStream());
bmp.Save("L:\\test\\111.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: