示例#1
0
        //获取编辑框已打开
        private bool hascommentOpened(mshtml.IHTMLElement commentTag)
        {
            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 == "comment-box-wrap")
                            {
                                return(true);
                            }
                        }
                        return(false);
                    }
                }
            }
            return(false);
        }
示例#2
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) { }
        }
示例#3
0
文件: Form1.cs 项目: a19284/JYSQ_JAVA
        //空间动态里的好友
        private void button9_Click(object sender, EventArgs e)
        {
            string info = "";

            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);

                for (int j = 0; j < frame.frames.length; ++j)
                {
                    try
                    {
                        object rj = j;
                        mshtml.IHTMLWindow2 frameWindow2 = frame.frames.item(ref rj) as mshtml.IHTMLWindow2;

                        IHTMLDocument2 frame2 = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow2);
                        mshtml.IHTMLElementCollection userlist = (mshtml.IHTMLElementCollection)frame2.all.tags("div");
                        IEnumerator users = userlist.GetEnumerator();
                        while (users.MoveNext())
                        {
                            mshtml.IHTMLElement element = (mshtml.IHTMLElement)users.Current;
                            if (element.className == "user-list" || element.className == "ui-avatar")
                            {
                                mshtml.IHTMLElementCollection childrenCol = (mshtml.IHTMLElementCollection)element.children;
                                IEnumerator cusers = childrenCol.GetEnumerator();
                                while (cusers.MoveNext())
                                {
                                    mshtml.IHTMLElement celement = (mshtml.IHTMLElement)cusers.Current;
                                    string href = (string)celement.getAttribute("href", 0);
                                    if (href.Contains("http:"))
                                    {
                                        info += href + "\n";
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            MessageBox.Show(info);
        }
示例#4
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);
        }
示例#5
0
        //检测是否已评论
        private mshtml.IHTMLElement gerCommented()
        {
            String myqq = getMyQQ();

            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 (element.className == "mod-comments")
                    {
                        mshtml.IHTMLElementCollection childrenCol = (mshtml.IHTMLElementCollection)element.all;
                        IEnumerator cusers    = childrenCol.GetEnumerator();
                        bool        cangonext = true;
                        while (cusers.MoveNext())
                        {
                            mshtml.IHTMLElement celement = (mshtml.IHTMLElement)cusers.Current;
                            Console.WriteLine(celement.className);
                            if (celement.className == "comments-item bor3")
                            {
                                if ((String)celement.getAttribute("data-uin", 0) == myqq)
                                {
                                    cangonext = false;
                                    break;
                                }
                            }
                        }
                        //1.打开编辑框
                        if (cangonext)//自己没有评论
                        {
                            return(element);
                        }
                    }
                }
            }
            return(null);
        }
示例#6
0
文件: Form1.cs 项目: a19284/JYSQ_JAVA
        //获取最后活跃时间
        private void button12_Click(object sender, EventArgs e)
        {
            string info = 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);

                for (int j = 0; j < frame.frames.length; ++j)
                {
                    object rj = j;
                    mshtml.IHTMLWindow2 frameWindow2 = frame.frames.item(ref rj) as mshtml.IHTMLWindow2;

                    IHTMLDocument2 frame2 = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow2);
                    mshtml.IHTMLElementCollection userlist = (mshtml.IHTMLElementCollection)frame2.all.tags("span");
                    IEnumerator users = userlist.GetEnumerator();
                    while (users.MoveNext())
                    {
                        mshtml.IHTMLElement element = (mshtml.IHTMLElement)users.Current;
                        string str = element.innerText;
                        if (str != null && str.Contains("月") && str.Contains("日") && str.Contains(":"))
                        {
                            info = str;
                            break;
                        }
                    }
                    if (info != null)
                    {
                        break;
                    }
                }
                if (info != null)
                {
                    break;
                }
            }
            MessageBox.Show(info);
        }
示例#7
0
        //检测是否评论成功
        private bool isCommentedSucc()
        {
            if (commentTag == null)
            {
                return(false);
            }
            String myqq = Func.getMyQQ(webBrowser1);

            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 == "comments-item bor3")
                            {
                                if (element2.innerHTML.Contains(myqq))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }
示例#8
0
        //2.编辑
        private mshtml.IHTMLElement commentStep2(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("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();
                        Console.WriteLine("|||||||||||||||||||||||||||||||||||||||||||||");
                        while (cusers.MoveNext())
                        {
                            mshtml.IHTMLElement element2 = (mshtml.IHTMLElement)cusers.Current;
                            Console.WriteLine(element2.className);
                            if (element2.className == "textinput textarea c_tx2")
                            {
                                element2.innerText = "哈哈:" + Environment.TickCount;
                                return(element);
                            }
                        }
                        Console.WriteLine("$$$$$$$$$$$$$$$$$$$$$$");
                    }
                }
            }
            return(null);
        }
示例#9
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);
        }
示例#10
0
文件: Form1.cs 项目: a19284/JYSQ_JAVA
        //获取【说说】的好友信息
        private void button7_Click(object sender, EventArgs e)
        {
            string info = 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 divs = (mshtml.IHTMLElementCollection)frame.all.tags("div");
                IEnumerator div = divs.GetEnumerator();
                while (div.MoveNext())
                {
                    mshtml.IHTMLElement item = (mshtml.IHTMLElement)div.Current;

                    if (item.className == "ui_avatar" || item.className == "feed_like")
                    {
                        mshtml.IHTMLElementCollection childrenCol = (mshtml.IHTMLElementCollection)item.children;
                        IEnumerator cusers = childrenCol.GetEnumerator();
                        while (cusers.MoveNext())
                        {
                            mshtml.IHTMLElement celement = (mshtml.IHTMLElement)cusers.Current;
                            if (celement.tagName == "a" || celement.tagName == "A")
                            {
                                string href = (string)celement.getAttribute("href", 0);
                                if (href != null && href.Contains("http:"))
                                {
                                    info += href + "\n";
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show(info);
        }
示例#11
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";
        }
示例#12
0
        //2.编辑
        private bool commentStep2(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 == "textinput textarea c_tx2" || element2.className == "textinput textarea c_tx2 input_focus textinput_focus")
                            //if (element2.className == "textinput textarea c_tx2 input_focus textinput_focus")
                            {
                                element2.innerText = getReplyStr();
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
示例#13
0
        //获取最后活跃时间
        private void getLasTime()
        {
            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);

                for (int j = 0; j < frame.frames.length; ++j)
                {
                    object rj = j;
                    mshtml.IHTMLWindow2 frameWindow2 = frame.frames.item(ref rj) as mshtml.IHTMLWindow2;

                    IHTMLDocument2 frame2 = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow2);
                    mshtml.IHTMLElementCollection userlist = (mshtml.IHTMLElementCollection)frame2.all.tags("span");
                    IEnumerator users = userlist.GetEnumerator();
                    while (users.MoveNext())
                    {
                        mshtml.IHTMLElement element = (mshtml.IHTMLElement)users.Current;
                        string str = element.innerText;
                        if (str != null && str.Contains("月") && str.Contains("日") && str.Contains(":"))
                        {
                            DateTime dnow = DateTime.Now;
                            str = str.Replace("月", "-");
                            str = str.Replace("日", "-");
                            str = str.Replace(" ", "");
                            str = str.Replace(":", "-");
                            str = String.Format("{0}-{1}-00", dnow.Year, str);
                            spider.UIDB.logintime = str;
                            return;
                        }
                    }
                }
            }
        }
示例#14
0
        //1.打开编辑框
        private mshtml.IHTMLElement commentStep1(mshtml.IHTMLElement commentTag)
        {
            String myqq = getMyQQ();

            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 == "textinput textinput-default bor2")
                            if (element1.className == "mod-commnets-poster feedClickCmd comment_default_inputentry")
                            {
                                element1.click();
                                return(element);
                            }
                        }
                    }
                }
            }
            return(null);
        }
示例#15
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();//失败后直接进入下一个
        }
示例#16
0
        public override void Tick()
        {
            if (Enable)
            {
                try
                {
                    string info = 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 divs = (mshtml.IHTMLElementCollection)frame.all.tags("div");
                        IEnumerator div = divs.GetEnumerator();
                        while (div.MoveNext())
                        {
                            mshtml.IHTMLElement item = (mshtml.IHTMLElement)div.Current;

                            if (item.className == "ui_avatar" || item.className == "feed_like")
                            {
                                mshtml.IHTMLElementCollection childrenCol = (mshtml.IHTMLElementCollection)item.children;
                                IEnumerator cusers = childrenCol.GetEnumerator();
                                while (cusers.MoveNext())
                                {
                                    mshtml.IHTMLElement celement = (mshtml.IHTMLElement)cusers.Current;
                                    if (celement.tagName == "a" || celement.tagName == "A")
                                    {
                                        string href = (string)celement.getAttribute("href", 0);
                                        if (href != null && href.Contains("http:"))
                                        {
                                            info += href + "\n";
                                            spider.AddQQ(href);
                                        }
                                    }
                                }
                            }
                        }
                    }


                    //string info = "";
                    //for (int i = 0; i < webBrowser1.Document.Window.Frames.Count; ++i)
                    //{
                    //    HtmlDocument frame = webBrowser1.Document.Window.Frames[i].Document;
                    //    HtmlElementCollection divs = frame.GetElementsByTagName("div");
                    //    for (int j = 0; j < divs.Count; ++j)
                    //    {
                    //        string className = divs[j].GetAttribute("className");
                    //        if (className == "ui_avatar")
                    //        {
                    //            HtmlElementCollection a = divs[j].GetElementsByTagName("a");
                    //            if (a != null && a.Count > 0)
                    //            {
                    //                string url = a[0].GetAttribute("href");
                    //                info += url + "\n";
                    //                spider.AddQQ(url);
                    //            }
                    //        }
                    //        else if (className == "feed_like")
                    //        {
                    //            HtmlElementCollection a = divs[j].GetElementsByTagName("a");
                    //            if (a != null && a.Count > 0)
                    //            {
                    //                for (int k = 0; k < a.Count; ++k)
                    //                {
                    //                    if (a[k].GetAttribute("className") == "c_tx")
                    //                    {
                    //                        string url = a[0].GetAttribute("href");
                    //                        info += url + "\n";
                    //                        spider.AddQQ(url);
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}

                    spider.UserGetOver();
                    Log(info);
                    ChangeCommon("NewUser");
                }
                catch (Exception e)
                {
                    Log(e.Message);
                    ChangeCommon("NewUser");
                }
            }
        }
示例#17
0
文件: Form1.cs 项目: a19284/JYSQ_JAVA
        //获取聊天内容(未完)
        private void button13_Click(object sender, EventArgs e)
        {
            string info = 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);

                for (int j = 0; j < frame.frames.length; ++j)
                {
                    object rj = j;
                    mshtml.IHTMLWindow2 frameWindow2 = frame.frames.item(ref rj) as mshtml.IHTMLWindow2;

                    IHTMLDocument2 frame2 = CodecentrixSample.CrossFrameIE.GetDocumentFromWindow(frameWindow2);

                    mshtml.IHTMLElement host_home_feeds = (mshtml.IHTMLElement)frame2.all.item("host_home_feeds", 0);
                    if (host_home_feeds != null)
                    {
                        mshtml.IHTMLElementCollection children = (mshtml.IHTMLElementCollection)host_home_feeds.children;
                        IEnumerator child = children.GetEnumerator();
                        while (child.MoveNext())//li
                        {
                            mshtml.IHTMLElement element = (mshtml.IHTMLElement)child.Current;
                            if (element.className == "f-single f-s-s")
                            {
                                mshtml.IHTMLElementCollection children2 = (mshtml.IHTMLElementCollection)element.children;
                                IEnumerator child2 = children2.GetEnumerator();
                                while (child2.MoveNext())
                                {
                                    mshtml.IHTMLElement element2 = (mshtml.IHTMLElement)child2.Current;
                                    if (element2.className == "f-wrap")
                                    {
                                        //太长了,未完
                                    }
                                }
                            }
                        }
                    }


                    //mshtml.IHTMLElementCollection userlist = (mshtml.IHTMLElementCollection)frame2.all.tags("div");
                    //IEnumerator users = userlist.GetEnumerator();
                    //while (users.MoveNext())
                    //{
                    //    mshtml.IHTMLElement element = (mshtml.IHTMLElement)users.Current;
                    //    if (element.className != null)
                    //        Console.WriteLine(element.className);

                    //    if (element.className == "comments-content" && element.innerText != null)
                    //    {
                    //        info += element.innerText + "|";
                    //        break;
                    //    }

                    //}
                }
            }
            MessageBox.Show(info);
        }