【发布时间】:2014-11-20 13:59:50
【问题描述】:
有什么方法可以将加载的图像从网络浏览器捕获或复制到图片框?
我要复制的图像是“验证码”图像,每个请求都会更改。我需要网页浏览器中加载的图片和图片框一样。
我已尝试拆分 img 标记并再次请求图像。它有效,但图片框图像与网络浏览器显示的不同。
这是我到目前为止所做的。它包含一个网络浏览器、一个图片框、一个文本框和一个按钮
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;
namespace arman_dobare_kir_mishavad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str2 = webBrowser1.DocumentText;
string[] strArray2;
strArray2 = Regex.Split(Regex.Split(str2, "<img id=\"content1_imgCaptcha\" src=\"")[1], "\"");
textBox1.Text = strArray2[0];
this.pictureBox1.ImageLocation = "http://www.hashkiller.co.uk" + strArray2[0];
return;
}
public void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
}
}
}
【问题讨论】:
-
告诉我们你做了什么
-
好的,我已经编辑了我的帖子...
-
调试时
strArray2[0]是什么? -
strarray2 是来自网站源的分割图像位置...
标签: c# browser picturebox