Реально рабочий пример получения изображения из WebBrowser на C#.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WebBrowserGetImage
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
HtmlDocument htmlDocument = this.webBrowser1.Document;
HtmlElementCollection htmlElementCollection = htmlDocument.Images;
foreach (HtmlElement htmlElement in htmlElementCollection)
{
string imgUrl = htmlElement.GetAttribute("src");
if (imgUrl.StartsWith("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjii4LsueWMRchpnjU2_-GGB05hF0ps3o-FCM0xocku_menSHqhEmDGh07Vr5nzonvZzFt_GmSEkyNEwocFk6R6eq5fvMnZqTyN5qi0HJclMDvcXP2fwYAiolJZDQrXUddlHYyYnd67tVZx/s1600/OpenVPN.png"))
{
this.pictureBox1.ImageLocation = imgUrl;
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://nmdsoft.blogspot.ru/");
}
}
}
Спасибо автору!
Комментариев нет:
Отправить комментарий