可以使用 webkitdotnet 通过 C# 中的 WebKit 浏览器下载文件吗?

发布于 2024-12-08 06:18:16 字数 1283 浏览 0 评论 0原文

我正在使用 WebKitDotNet 来模拟和自动化 Web 浏览器。这真的很漂亮并且在大多数方面都有效。但是,当我尝试实现此代码时,WebKit 不会触发下载:

WebKitBrowser _b = null;

private void button1_Click(object sender, EventArgs e)
{
    _b = new WebKitBrowser();
    _b.DownloadBegin += new FileDownloadBeginEventHandler(b_DownloadBegin);
    _b.Error += new WebKitBrowserErrorEventHandler(_b_Error);
    _b.AllowDownloads = true;
    _b.Navigate("http://sourceforge.net/projects/webkitdotnet/files/WebKit%20.NET%200.x/0.5/WebKit.NET-0.5-bin-cairo.zip/download");
}

void _b_Error(object sender, WebKitBrowserErrorEventArgs e)
{
    MessageBox.Show("error!");
}

void b_DownloadBegin(object sender, FileDownloadBeginEventArgs e)
{
    MessageBox.Show("hi");
}

“Error”和“DownloadBegin”事件都不会触发。我希望他们中至少有一个会这样做 - 是否有我缺少的设置?

编辑:我知道这是一个老问题,但这是更新。当我写这个问题时,我试图自动化一个需要人类每天一次登录网站、提供凭据并单击下载链接的过程。我们希望能够以编程方式完成这项工作,以减轻负责这项工作的穷人的单调感。

不幸的是,WebKitDotNet 没有成功完成这项任务。尽管在基于 webkit 的浏览器中,您可以单击链接并触发下载,但在嵌入式 WebKitDotNet 中,单击链接不会执行任何操作。我的猜测是 WebKitDotNet 中的某些内容丢失了该事件。如果有人想测试这个,可以使用Sourceforge下载链接进行测试。

我团队中的一个人最终通过使用名为“IMacros”的 Internet Explorer 自动化工具解决了这个问题。我们选择这个产品是因为1)我们可以保证每台运行该程序的计算机上都安装了IE,2)IMacros 可以正确接收来自网站的事件并触发文件下载。

I'm using WebKitDotNet to simulate and automate a web browser. This is really nifty and works in most respects. However, when I try to implement this code, WebKit doesn't trigger a download:

WebKitBrowser _b = null;

private void button1_Click(object sender, EventArgs e)
{
    _b = new WebKitBrowser();
    _b.DownloadBegin += new FileDownloadBeginEventHandler(b_DownloadBegin);
    _b.Error += new WebKitBrowserErrorEventHandler(_b_Error);
    _b.AllowDownloads = true;
    _b.Navigate("http://sourceforge.net/projects/webkitdotnet/files/WebKit%20.NET%200.x/0.5/WebKit.NET-0.5-bin-cairo.zip/download");
}

void _b_Error(object sender, WebKitBrowserErrorEventArgs e)
{
    MessageBox.Show("error!");
}

void b_DownloadBegin(object sender, FileDownloadBeginEventArgs e)
{
    MessageBox.Show("hi");
}

Neither the "Error" nor the "DownloadBegin" events fire. I would expect at least one of them to do so - is there a setting that I'm missing?

EDIT: I know this is an old question, but here's the update. When I wrote this question, I was trying to automate a process that required a human being - once per day - to log onto a website, provide credentials, and click a download link. We were hoping to be able to do this programmatically to relieve the monotony for the poor person tasked with doing this job.

Unfortunately, WebKitDotNet did not succeed in this task. Although, in a webkit based browser, you can click on the link and trigger a download, in the embedded WebKitDotNet clicking on the link did nothing. My guess is that something within WebKitDotNet lost the event. If anyone wants to test this, you can use the Sourceforge download link to test.

One of the guys on my team did eventually solve this problem by using an Internet Explorer automation tool called "IMacros". We selected this product because 1) We could guarantee that IE was installed on every computer that would run the program, and 2) IMacros could correctly receive the event from the website and trigger the file download.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

活雷疯 2024-12-15 06:18:16

问题跟踪器上有一个 2011 年 3 月 24 日的发布日期,其中指出下载尚无法进行:

https://github.com/webkitdotnet/webkitdotnet/issues/7

由于跟踪器中几乎没有问题,因此如果同时添加该功能,它可能会被标记为已解决。

On the Issue tracker there is a post date from March 24, 2011 in which is stated that download does not work yet:

https://github.com/webkitdotnet/webkitdotnet/issues/7

Since there are few issues in the tracker, it would have probably been marked as resolved if the feature was added meantime.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文