示例#1
0
        private void PraiseFriend()
        {
            try
            {
                mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;

                for (int i = 0; i < htmlDoc.frames.length; ++i)
                {
                    object index = i;
                    mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                    IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                    mshtml.IHTMLElementCollection tagls = (mshtml.IHTMLElementCollection)frame.all.tags("a");
                    IEnumerator tagie = tagls.GetEnumerator();
                    while (tagie.MoveNext())
                    {
                        mshtml.IHTMLElement element = (mshtml.IHTMLElement)tagie.Current;
                        if (element.className == "item qz_like_btn_v3")
                        {
                            if (element.innerText != null && !element.innerText.Contains("取消赞"))
                            {
                                element.click();
                                praisedMap.Add(curQQ);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception) { }
        }
示例#2
0
        //로그인 과정
        private void login()
        {
            if (doc.GetElementById("login-input") != null)
            {
                nStep = "trylogin";

                doc.GetElementById("id-pw").GetElementsByTagName("input").GetElementsByName("user_id")[0].SetAttribute("value", user_id);
                doc.GetElementById("id-pw").GetElementsByTagName("input").GetElementsByName("password")[0].SetAttribute("value", user_pw);

                mshtml.IHTMLElement hel = doc.GetElementById("login-process").GetElementsByTagName("input")[0].DomElement as mshtml.IHTMLElement;
                hel.click();
            }
        }
示例#3
0
        //3.提交
        private bool commentStep3ex(mshtml.IHTMLElement commentTag)
        {
            if (commentTag == null)
            {
                return(false);
            }
            mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;
            for (int i = 0; i < htmlDoc.frames.length; ++i)
            {
                object index = i;
                mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                mshtml.IHTMLElementCollection tagls = (mshtml.IHTMLElementCollection)frame.all.tags("div");
                IEnumerator tagie = tagls.GetEnumerator();
                while (tagie.MoveNext())
                {
                    mshtml.IHTMLElement element = (mshtml.IHTMLElement)tagie.Current;
                    if (commentTag == element && element.className == "mod-comments")
                    {
                        mshtml.IHTMLElementCollection childrenCol = (mshtml.IHTMLElementCollection)element.all;
                        IEnumerator cusers = childrenCol.GetEnumerator();
                        while (cusers.MoveNext())
                        {
                            mshtml.IHTMLElement element2 = (mshtml.IHTMLElement)cusers.Current;
                            if (element2.className == "btn-post gb_bt  evt_click")
                            {
                                element2.click();
                                return(true);

//                                 mshtml.IHTMLElementCollection element2Col = (mshtml.IHTMLElementCollection)element2.all;
//                                 IEnumerator element2Cols = element2Col.GetEnumerator();
//                                 while (element2Cols.MoveNext())
//                                 {
//                                     mshtml.IHTMLElement element3 = (mshtml.IHTMLElement)element2Cols.Current;
//                                     if (element3.className == "btn-post gb_bt  evt_click")
//                                     {
//                                         element3.click();
//                                         return commentTag;
//                                     }
//                                 }
                            }
                        }
                    }
                }
            }
            return(false);
        }
示例#4
0
文件: Form1.cs 项目: a19284/JYSQ_JAVA
        //切换到账号输入
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;
                object index = 0;
                mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                mshtml.IHTMLElementCollection logins  = (mshtml.IHTMLElementCollection)frame.all.tags("a");
                mshtml.IHTMLElement           element = (mshtml.IHTMLElement)logins.item("switcher_plogin", 0);
                element.click();
            }
            catch (System.Exception _e)
            {
                Console.Write(_e.Message);
            }
        }
示例#5
0
        //3.提交
        private mshtml.IHTMLElement commentStep3(mshtml.IHTMLElement commentTag)
        {
            if (commentTag == null)
            {
                return(null);
            }
            mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;
            for (int i = 0; i < htmlDoc.frames.length; ++i)
            {
                object index = i;
                mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                mshtml.IHTMLElementCollection tagls = (mshtml.IHTMLElementCollection)frame.all.tags("a");
                IEnumerator tagie = tagls.GetEnumerator();
                while (tagie.MoveNext())
                {
                    try
                    {
                        mshtml.IHTMLElement element = (mshtml.IHTMLElement)tagie.Current;
                        if (element.className == "btn-post gb_bt  evt_click" &&
                            element.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement == commentTag)
                        {
                            element.click();
                            CommentMap.Add(curQQ);
                            return(commentTag);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("*********************************************************");
                        Console.WriteLine(ex.ToString());
                        Console.WriteLine("*********************************************************");
                    }
                }
            }
            return(null);
        }
        private bool GotoNextPage(WebBrowser wb, bool isLastPage)
        {
            mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)wb.Document;
            // string html =  doc2.body.innerHTML;
            var currentUrl = wb.Source.AbsoluteUri;

            currentUrl = currentUrl.Replace("#", "");
            if (currentUrl == this.TargetUri)
            {
                mshtml.IHTMLElement example1_next = (mshtml.IHTMLElement)doc2.all.item("example1_next", 0);
                example1_next.click();

                int pageCounter = 0;
                var pagenumStr  = example1_next.getAttribute("data-dt-idx");
                if (!int.TryParse(pagenumStr.ToString(), out pageCounter))
                {
                    MessageBox.Show(string.Format("翻页失败,请手工执行"));
                }


                //边界条件
                var classstr = example1_next.getAttribute("class");
                if (classstr == null)
                {
                    MessageBox.Show(string.Format("example1_next miss {0} attr,请手工点击[下一页]", "class"));
                }
                else
                {
                    if (classstr.ToString().Contains("disabled"))
                    {
                        isLastPage = true;
                    }
                }

                // class = paginate_button current 定
            }

            return(isLastPage);
        }
示例#7
0
        private void PraiseFriendFix()
        {
            try
            {
                mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;

                for (int i = 0; i < htmlDoc.frames.length; ++i)
                {
                    object index = i;
                    mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                    IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                    mshtml.IHTMLElementCollection tagls = (mshtml.IHTMLElementCollection)frame.all.tags("A");
                    IEnumerator tagie = tagls.GetEnumerator();
                    while (tagie.MoveNext())
                    {
                        mshtml.IHTMLElement element = (mshtml.IHTMLElement)tagie.Current;
                        if (element.className == "qz_like_btn c_tx mr8")
                        {
                            string style = (string)element.style.cssText;

                            if (element.innerText != null && element.innerText.Contains("取消赞") && style != "display: none;")
                            {
                                element.click();
                                success.Add(curQQ);

                                richTextBox1.Text = richTextBox1.Text + "【成功】" + curQQ + "\n";
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception) { }

            failed.Add(curQQ);
            richTextBox1.Text = richTextBox1.Text + "【失败】" + curQQ + "\n";
        }
示例#8
0
        //1.打开编辑框
        private bool commentStep1(mshtml.IHTMLElement commentTag)
        {
            if (hascommentOpened(commentTag))
            {
                return(true);
            }
            mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;
            for (int i = 0; i < htmlDoc.frames.length; ++i)
            {
                object index = i;
                mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                mshtml.IHTMLElementCollection tagls = (mshtml.IHTMLElementCollection)frame.all.tags("div");
                IEnumerator tagie = tagls.GetEnumerator();
                while (tagie.MoveNext())
                {
                    mshtml.IHTMLElement element = (mshtml.IHTMLElement)tagie.Current;
                    if (commentTag == element && element.className == "mod-comments")
                    {
                        mshtml.IHTMLElementCollection childrenCol = (mshtml.IHTMLElementCollection)element.all;
                        IEnumerator cusers = childrenCol.GetEnumerator();
                        while (cusers.MoveNext())
                        {
                            mshtml.IHTMLElement element1 = (mshtml.IHTMLElement)cusers.Current;
                            if (element1.className == "mod-commnets-poster feedClickCmd comment_default_inputentry")
                            {
                                element1.click();
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
示例#9
0
        //actually it is replay // mock
        private void pause_Click(object sender, EventArgs e)
        {
            //lauch a new browser
            IHTMLDocument2     doc   = null;
            InternetExplorer   ie    = LauchBrowser();
            TreeNodeCollection nodes = SteptreeView.Nodes[0].Nodes;

            //foreach (TreeNode node in nodes)
            //{
            if (nodes[0].Text.StartsWith("Browser ; "))
            {
                string txt             = nodes[0].Text;
                string str             = "Browser ; " + BrowserActionEnum.Nav;
                int    start           = txt.IndexOf(str);
                int    end             = txt.IndexOf(";time cost:");
                string url             = txt.Substring(start + str.Length, end - start - str.Length);
                object Flags           = new object();
                object TargetFrameName = new object();
                object PostData        = new object();
                object Headers         = new object();
                ie.Navigate(url, ref Flags, ref TargetFrameName, ref PostData, ref Headers);
            }
            Thread.Sleep(5000);

            doc = ie.Document as IHTMLDocument2;

            mshtml.IHTMLElementCollection inputs;
            inputs = (mshtml.IHTMLElementCollection)doc.all.tags("INPUT");
            mshtml.IHTMLElement elementTxt = (mshtml.IHTMLElement)inputs.item("q", 0);
            ((IHTMLInputElement)elementTxt).value = "GBS";
            Thread.Sleep(3000);
            mshtml.IHTMLElement element = (mshtml.IHTMLElement)inputs.item("btnG", 0);
            element.click();

            //}
        }
示例#10
0
        private void PraiseFriend()
        {
            try
            {
                mshtml.HTMLDocumentClass htmlDoc = webBrowser1.Document.DomDocument as mshtml.HTMLDocumentClass;

                for (int i = 0; i < htmlDoc.frames.length; ++i)
                {
                    object index = i;
                    mshtml.IHTMLWindow2 frameWindow = htmlDoc.frames.item(ref index) as mshtml.IHTMLWindow2;

                    IHTMLDocument2 frame = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow);

                    mshtml.IHTMLElementCollection tagls = (mshtml.IHTMLElementCollection)frame.all.tags("A");
                    IEnumerator tagie = tagls.GetEnumerator();
                    while (tagie.MoveNext())
                    {
                        mshtml.IHTMLElement element = (mshtml.IHTMLElement)tagie.Current;
                        if (element.className == "qz_like_btn c_tx mr8")
                        {
                            if (element.innerText != null && !element.innerText.Contains("取消赞"))
                            {
                                element.click();
                                pro = "点赞完成";
                                //richTextBox1.Text = richTextBox1.Text + "【成功】" + curQQ + "\n";
                                return;
                            }
                        }
                    }
                }
            }
            catch (Exception) { }

            //richTextBox1.Text = richTextBox1.Text + "【失败】" + curQQ + "\n";
            Zhan();//失败后直接进入下一个
        }