简体   繁体   English

DocumentCompleted之前使用WebBrowser解析网页

[英]Parsing a webpage with WebBrowser before DocumentCompleted

There is a web page (call it main) that contains several frames. 有一个网页(称为主页面)包含多个框架。

The main and all its included frames raise event DocumentCompleted . 主框架及其所有包含的框架引发事件DocumentCompleted

The order of those events is: Subframe1, subframe2, subframeX.., main. 这些事件的顺序是:子帧1,子帧2,子帧X..main。

What I want is to parse the content of the main and add some handlers on several html elements on it before the user can take any action. 我想要的是解析主体的内容,并在用户可以执行任何操作之前在其上的几个html元素上添加一些处理程序。 (For example button.Click or link.Click ). (例如, button.Clickbutton.Clicklink.Clicklink.Click )。 Till now this is possible by waiting the DocumentCompleted and checking the event's arguments for the correct frame. 到现在为止,可以通过等待DocumentCompleted并检查事件的参数以获取正确的帧来实现。

However, sometimes the included frames happen to take much time to load and the desired event is not raised within a reasonal amount of time. 但是,有时包含的帧恰好需要花费很多时间来加载,并且在合理的时间内未引发所需的事件。 However the page is visible by the user despite the fact that parsing and the addition of the handlers cannot be done. 但是,尽管无法完成解析和添加处理程序,但用户仍可以看到该页面。

So the impatient user interacts with the page, which messes up all the work. 因此,急躁的用户会与页面进行交互,从而使所有工作变得混乱。

Is there a recommended way to parse the page sooner without waiting for DocumentCompleted (as long as the data is there of course) and keep doing it silently (that is: not show a waiting form or popup to the user)? 有没有推荐的方法可以在不等待DocumentCompleted (当然只要有数据)的情况下就更快地解析页面并保持静默运行(即:不向用户显示等待表单或弹出窗口)?

您可以使用“ Navigated”事件,请看这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM