Пример #1
0
        void IAutoWeb.Next(WebBrowser webBrowser1)
        {
            Uri url = webBrowser1.Url;
            // Fix bug: Why sometimes it's null?
            if(url == null)
            {
                return;
            }

            Console.Out.WriteLine("Next>>");
            Console.Out.WriteLine(url);

            if (url.ToString().StartsWith(URL_LOGIN))
            {
                this.LoginSupportedByWangWang(webBrowser1.Document);
            }
            else if (url.ToString().StartsWith(URL_ASSET))
            {
                MoneyDatabaseUpdater dbUpdater = new MoneyDatabaseUpdater();
                if (this._isTotalUpdated == false)
                {
                    this._isTotalUpdated = this.RetrieveTotal(webBrowser1.Document, dbUpdater);
                }

                if (this.RetrieveDaily(webBrowser1.Document, dbUpdater))
                {
                    if (!this.ClickNextTab(webBrowser1.Document))
                    {
                        webBrowser1.Navigate(URL_MIAO);
                    }
                }
            }
            else if (url.ToString().StartsWith(URL_MIAO))
            {
                if (this.GetMaoquan(webBrowser1.Document))
                {
                    webBrowser1.Navigate(URL_ETAO);
                }
            }
            else if (url.ToString().StartsWith(URL_ETAO))
            {
                if (this.SignETao(webBrowser1.Document))
                {
                    this._completed = true;
                }
            }
            else
            {

            }
        }
Пример #2
0
        private bool RetrieveTotal(HtmlDocument doc, MoneyDatabaseUpdater dbUpdater)
        {
            double earn = 0;
            double left = 0;
            foreach (HtmlElement eleTd in doc.GetElementsByTagName("h3"))
            {
                string textTotal = eleTd.InnerText;
                if (eleTd.InnerText.Contains("总金额"))
                {
                    left = this.GetAmountFromText(eleTd.InnerText);
                }
                else if (eleTd.InnerText.Contains("历史累计收益"))
                {
                    earn = this.GetAmountFromText(eleTd.Parent.GetElementsByTagName("div")[0].InnerText);
                }
            }
            this._message = string.Format("今日\r\n余额:{0}元\r\n累计收益:{1}元", left, earn);

            dbUpdater.AddTotal(DateTime.Now, earn, left);
            return true;
        }
Пример #3
0
        private bool RetrieveDaily(HtmlDocument doc, MoneyDatabaseUpdater dbUpdater)
        {
            bool isRetrievedAny = false;

            foreach (HtmlElement eleTr in doc.GetElementsByTagName("tr"))
            {
                DateTime billTime = DateTime.Now;
                double amount = 0;
                byte changeType = 0;

                foreach(HtmlElement eleTd in eleTr.Children)
                {
                    string className = eleTd.GetAttribute("classname");
                    if (className.Contains("billTime"))
                    {
                        try
                        {
                            billTime = DateTime.Parse(eleTd.InnerText);
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    else if (className.Contains("ft-bold"))
                    {
                        amount = this.GetAmountFromText(eleTd.InnerText);
                    }
                    else if (className.Contains("billAmount"))
                    {
                        changeType = this.GetTypeFromText(eleTd.InnerText);
                    }
                }

                if (amount != 0)
                {
                    Debug.Assert(changeType != 0, "未知的类型出现了!");
                    dbUpdater.AddDaily(billTime, amount, changeType);
                    isRetrievedAny = true;
                }
            }

            return isRetrievedAny;
        }