日期:2014-05-17 浏览次数:20816 次
webWow.Document.GetElementById("accountName").SetAttribute("value", "1@163.com");
webWow.Document.GetElementById("password").SetAttribute("value", "1");
HtmlElement htmlEle = webWow.Document.Forms["form"];
htmlEle.InvokeMember("submit");
public class Rule
{
public Func<bool> CheckCondition; //判断此规则的执行条件是否具备
public Action<> TakeConclusion; //执行此规则,使得整个执行环境推进到下一个状态
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs arg)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
var r = Rules.FirstOrDefault(x => x.CheckCondition()); //找到一个可以执行条件具备了的规则
if (r != null)
r.TakeConclusion(arg); //执行这个规则的结论部分
}
}
private static Random Rnd = new Random();
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs arg)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
var r = Rules.OrderBy(x => Rnd.Next()).FirstOrDefault(x => x.CheckCondition());
if (r != null)
r.TakeConclusion(arg);
}
}