Ejemplo n.º 1
0
        void _httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            this._CompletedCount++;
            if (e.Error == null)
            {
                System.Text.RegularExpressions.MatchCollection mc = RegexUtility.GetMatchFull(e.ResponseString, ((ProxySourcePageInfo)e.UserState).RegexString);
                if (mc != null)
                {
                    foreach (System.Text.RegularExpressions.Match m in mc)
                    {
                        ProxyInfo info = new ProxyInfo();
                        info.Name    = "";
                        info.Address = m.Groups[1].Value.Split(':')[0];
                        info.Port    = Convert.ToInt32(m.Groups[1].Value.Split(':')[1]);
                        SendStatusChanged(string.Format("取得:{0}:{1}", info.Address, info.Port), "");
                        this._ProxyList.Add(info);
                    }
                }
            }
            else
            {
#warning todo error
            }
            if (this._CompletedCount == this._SourcePageInfo.Count)
            {
                if (this.Completed != null)
                {
                    this.Completed(this, new Natsuhime.Events.ReturnCompletedEventArgs(this._ProxyList, null, false, "77777"));
                }
            }
        }
Ejemplo n.º 2
0
 void httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         this.GetFileUrlsComplete(e.ResponseString, e.UserState, e.Cancelled);
     }
     else
     {
         OnCompleted(new ReturnCompletedEventArgs(null, e.Error, e.Cancelled, e.UserState));
     }
 }
Ejemplo n.º 3
0
 void httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (ckbxUserWebBrowser.Checked)
         {
             this.wbMain.DocumentText = e.ResponseString;
         }
         ShowMessage(e.ResponseString);
         ShowCookie();
         ShowMessage("END REQUEST:");
     }
     else
     {
         GetException(e.Error);
     }
 }
Ejemplo n.º 4
0
 void SendLoginInfoCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.ResponseString.IndexOf("欢迎您回来") > -1)
         {
             this._SendLoginComplete(this, true, e.ResponseString, null);
         }
         else
         {
             this._SendLoginComplete(this, false, "没有匹配到成功字符串:\r\n" + e.ResponseString, null);
         }
     }
     else
     {
         _SendLoginComplete(sender, false, "发送登录信息异常", e.Error);
     }
 }
Ejemplo n.º 5
0
        void SendCreateThreadInfoCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            AsyncObject             ao      = e.UserState as AsyncObject;
            List <CreateThreadInfo> ctiList = ao.MySetObject as List <CreateThreadInfo>;

            if (e.Error == null)
            {
                if (e.ResponseString.IndexOf("您的帖子已经发布") > -1)
                {
                    _SendCreateThreadInofProgressChange(this, true, "", null);
                }
                else
                {
                    string errorMessage = string.Format(
                        "没有捕获到发帖成功文字:\r\n{0}\r\n\r\n\r\nfid:{1}\r\ntid:{2}\r\ntitle:{3}",
                        e.ResponseString,
                        ctiList[0].fid,
                        ctiList[0].tid,
                        ctiList[0].Subject
                        );
                    _SendCreateThreadInofProgressChange(this, false, errorMessage, null);
                }
            }
            else
            {
                string errorMessage = string.Format(
                    "发布主题异常:\r\n{0}\r\n\r\n\r\nfid:{1}\r\ntid:{2}\r\ntitle:{3}",
                    e.ResponseString,
                    ctiList[0].fid,
                    ctiList[0].tid,
                    ctiList[0].Subject
                    );
                _SendCreateThreadInofProgressChange(sender, false, errorMessage, e.Error);
            }
            ctiList.Remove(ctiList[0]);
            if (ctiList.Count > 0)
            {
                DoCreateThreadInfo(ctiList);
            }
            else
            {
                _SendCreateThreadInfoComplete(this, true, "", null);
            }
        }
Ejemplo n.º 6
0
        void nhttper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string baseUrl = tbxUrl.Text.Trim().Substring(0, tbxUrl.Text.Trim().LastIndexOf('/') + 1);

                if (e.UserState.ToString() == "GetTitleUrls")
                {
                    GetTitleUrlsComplete(e.ResponseString, baseUrl);
                }
                else if (e.UserState.ToString() == "GetImageUrls")
                {
                    GetImageUrlsComplete(e.ResponseString, baseUrl);
                }
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Ejemplo n.º 7
0
 void InitCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         string formhash = Security.GetFormHash(e.ResponseString);
         if (formhash != null && formhash != string.Empty)
         {
             this._formhash = formhash;
             SendLoginInfo();
         }
         else
         {
             this._SendLoginComplete(this, false, "获取FormHash失败", null);
         }
     }
     else
     {
         _SendLoginComplete(sender, false, "获取FormHash异常", e.Error);
     }
 }
Ejemplo n.º 8
0
        void _httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            AsyncObject ao = e.UserState as AsyncObject;
            string step = ao.MySetId.ToString();

            if (step == "InitCompleted")
            {
                this.InitCompleted(sender, e);
            }
            else if (step == "SendLoginInfoCompleted")
            {
                this.SendLoginInfoCompleted(sender, e);
            }
            else if (step == "InitCreateThreadCompleted")
            {
                this.InitCreateThreadCompleted(sender, e);
            }
            else if (step == "SendCreateThreadInfoCompleted")
            {
                this.SendCreateThreadInfoCompleted(sender, e);
            }
        }
Ejemplo n.º 9
0
        void InitCreateThreadCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string formhash = Security.GetFormHash(e.ResponseString);
                if (formhash != null && formhash != string.Empty)
                {
                    this._formhash = formhash;

                    AsyncObject ao = e.UserState as AsyncObject;
                    SendCreateThreadInfo(ao.MySetObject as List <CreateThreadInfo>);
                }
                else
                {
                    this._SendCreateThreadInfoComplete(this, false, "获取FormHash失败", null);
                }
            }
            else
            {
                _SendCreateThreadInfoComplete(sender, false, "获取FormHash异常", e.Error);
            }
        }
Ejemplo n.º 10
0
        void _httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            AsyncObject ao   = e.UserState as AsyncObject;
            string      step = ao.MySetId.ToString();

            if (step == "InitCompleted")
            {
                this.InitCompleted(sender, e);
            }
            else if (step == "SendLoginInfoCompleted")
            {
                this.SendLoginInfoCompleted(sender, e);
            }
            else if (step == "InitCreateThreadCompleted")
            {
                this.InitCreateThreadCompleted(sender, e);
            }
            else if (step == "SendCreateThreadInfoCompleted")
            {
                this.SendCreateThreadInfoCompleted(sender, e);
            }
        }
Ejemplo n.º 11
0
 void httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         string[] urls = Utils.GetImageUrls(e.ResponseString);
         if (urls.Length > 0)
         {
             MessageBox.Show(string.Format("{0} Images Getted~", urls.Length));
             foreach (string url in urls)
             {
                 tbxResult.Text += url + Environment.NewLine;
             }
         }
         else
         {
             MessageBox.Show("No Image Getted!");
         }
     }
     else
     {
         MessageBox.Show(e.Error.Message);
     }
 }
Ejemplo n.º 12
0
        void httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                if (e.ResponseString != string.Empty)
                {
                    if (e.UserState.ToString() == "GETLIST")
                    {
                        #region 获取列表
                        #region 正则
                        MatchCollection mc = RegexUtility.GetMatchFull(e.ResponseString, tbxPreListRegex.Text.Trim(), RegexOptions.Singleline | RegexOptions.IgnoreCase);
                        if (mc != null)
                        {
                            foreach (Match m in mc)
                            {
                                WebContentListInfo wcli = new WebContentListInfo();
                                wcli.Title       = m.Groups[1].Value.Trim();
                                wcli.ContentList = new List <WebContentInfo>();

                                MatchCollection mcContent = RegexUtility.GetMatchFull(m.Groups[2].Value, tbxListRegex.Text.Trim());
                                if (mcContent != null)
                                {
                                    foreach (Match mContent in mcContent)
                                    {
                                        WebContentInfo wci = new WebContentInfo();
                                        wci.Title = mContent.Groups[2].Value.Trim();
                                        wci.Url   = mContent.Groups[1].Value.Trim();

                                        wcli.ContentList.Add(wci);
                                    }

                                    WebContentLists.Add(wcli);
                                }
                            }
                        }
                        #endregion
                        #region 显示
                        this.lvList.Items.Clear();
                        foreach (WebContentInfo info in WebContentLists[0].ContentList)
                        {
                            ListViewItem lv = new ListViewItem(info.Title);

                            ListViewItem.ListViewSubItem lvsi  = new ListViewItem.ListViewSubItem(lv, info.Url);
                            ListViewItem.ListViewSubItem lvsi2 = new ListViewItem.ListViewSubItem(lv, info.Title);

                            lv.SubItems.Add(lvsi);
                            lv.SubItems.Add(lvsi2);

                            this.lvList.Items.Add(lv);
                        }
                        MessageBox.Show(this, string.Format("{0}章完成!", WebContentLists.Count));
                        this.btnGetList.Enabled = true;
                        #endregion }
                        #endregion
                    }
                    else
                    {
                        #region 获取内容
                        WebContentInfo wci = (WebContentInfo)e.UserState;

                        string content = RegexUtility.ReplaceRegex(
                            tbxPreContentRegex.Text.Trim(),
                            e.ResponseString,
                            "",
                            RegexOptions.Singleline | RegexOptions.IgnoreCase
                            );
                        MatchCollection mc = RegexUtility.GetMatchFull(
                            content,
                            tbxContentRegex.Text.Trim(),
                            RegexOptions.Singleline | RegexOptions.IgnoreCase
                            );
                        if (mc != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.Append(wci.Title + Environment.NewLine);
                            foreach (Match m in mc)
                            {
                                if (m.Groups[1].Value.IndexOf("盗墓笔记网友留言") < 0)
                                {
                                    sb.Append(m.Groups[1].Value + Environment.NewLine);
                                }
                            }
                            sb.Append(Environment.NewLine);
                            sb.Append(Environment.NewLine);


                            string savepath = Path.Combine(
                                AppDomain.CurrentDomain.BaseDirectory,
                                "down"
                                );
                            if (!Directory.Exists(savepath))
                            {
                                Directory.CreateDirectory(savepath);
                            }

                            try
                            {
                                FileStream fs = new FileStream(
                                    Path.Combine(savepath, this.WebContentLists[0].Title + ".txt"),
                                    FileMode.Append
                                    );
                                StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(true, true));
                                sw.Write(Natsuhime.Web.Utils.RemoveHtml(sb.ToString()));
                                sw.Flush();
                                sw.Close();
                                fs.Close();


                                this.WebContentLists[0].ContentList.Remove(wci);
                                DownNextContent();
                            }
                            catch (Exception ex)
                            {
                                this.btnGetContent.Enabled = true;
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    MessageBox.Show("返回空");
                }
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }
        }
Ejemplo n.º 13
0
 void InitCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         string formhash = Security.GetFormHash(e.ResponseString);
         if (formhash != null && formhash != string.Empty)
         {
             this._formhash = formhash;
             SendLoginInfo();
         }
         else
         {
             this._SendLoginComplete(this, false, "获取FormHash失败", null);
         }
     }
     else
     {
         _SendLoginComplete(sender, false, "获取FormHash异常", e.Error);
     }
 }
Ejemplo n.º 14
0
 void SendLoginInfoCompleted(object sender, RequestStringCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (e.ResponseString.IndexOf("欢迎您回来") > -1)
         {
             this._SendLoginComplete(this, true, e.ResponseString, null);
         }
         else
         {
             this._SendLoginComplete(this, false, "没有匹配到成功字符串:\r\n" + e.ResponseString, null);
         }
     }
     else
     {
         _SendLoginComplete(sender, false, "发送登录信息异常", e.Error);
     }
 }
Ejemplo n.º 15
0
        void InitCreateThreadCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                string formhash = Security.GetFormHash(e.ResponseString);
                if (formhash != null && formhash != string.Empty)
                {
                    this._formhash = formhash;

                    AsyncObject ao = e.UserState as AsyncObject;
                    SendCreateThreadInfo(ao.MySetObject as List<CreateThreadInfo>);
                }
                else
                {
                    this._SendCreateThreadInfoComplete(this, false, "获取FormHash失败", null);
                }
            }
            else
            {
                _SendCreateThreadInfoComplete(sender, false, "获取FormHash异常", e.Error);
            }
        }
Ejemplo n.º 16
0
        void SendCreateThreadInfoCompleted(object sender, RequestStringCompletedEventArgs e)
        {
            AsyncObject ao = e.UserState as AsyncObject;
            List<CreateThreadInfo> ctiList = ao.MySetObject as List<CreateThreadInfo>;
            if (e.Error == null)
            {
                if (e.ResponseString.IndexOf("您的帖子已经发布") > -1)
                {
                    _SendCreateThreadInofProgressChange(this, true, "", null);
                }
                else
                {
                    string errorMessage = string.Format(
                        "没有捕获到发帖成功文字:\r\n{0}\r\n\r\n\r\nfid:{1}\r\ntid:{2}\r\ntitle:{3}",
                        e.ResponseString,
                        ctiList[0].fid,
                        ctiList[0].tid,
                        ctiList[0].Subject
                        );
                    _SendCreateThreadInofProgressChange(this, false, errorMessage, null);
                }
            }
            else
            {
                string errorMessage = string.Format(
                    "发布主题异常:\r\n{0}\r\n\r\n\r\nfid:{1}\r\ntid:{2}\r\ntitle:{3}",
                    e.ResponseString,
                    ctiList[0].fid,
                    ctiList[0].tid,
                    ctiList[0].Subject
                    );
                _SendCreateThreadInofProgressChange(sender, false, errorMessage, e.Error);
            }
            ctiList.Remove(ctiList[0]);
            if (ctiList.Count > 0)
            {
                DoCreateThreadInfo(ctiList);
            }
            else
            {
                _SendCreateThreadInfoComplete(this, true, "", null);
            }

        }
Ejemplo n.º 17
0
        void httper_RequestStringCompleted(object sender, RequestStringCompletedEventArgs e)
        {

            if (e.Error == null)
            {
                if (e.ResponseString != string.Empty)
                {
                    if (e.UserState.ToString() == "GETLIST")
                    {
                        #region 获取列表
                        #region 正则
                        MatchCollection mc = RegexUtility.GetMatchFull(e.ResponseString, tbxPreListRegex.Text.Trim(), RegexOptions.Singleline | RegexOptions.IgnoreCase);
                        if (mc != null)
                        {
                            foreach (Match m in mc)
                            {
                                WebContentListInfo wcli = new WebContentListInfo();
                                wcli.Title = m.Groups[1].Value.Trim();
                                wcli.ContentList = new List<WebContentInfo>();

                                MatchCollection mcContent = RegexUtility.GetMatchFull(m.Groups[2].Value, tbxListRegex.Text.Trim());
                                if (mcContent != null)
                                {
                                    foreach (Match mContent in mcContent)
                                    {
                                        WebContentInfo wci = new WebContentInfo();
                                        wci.Title = mContent.Groups[2].Value.Trim();
                                        wci.Url = mContent.Groups[1].Value.Trim();

                                        wcli.ContentList.Add(wci);
                                    }

                                    WebContentLists.Add(wcli);
                                }
                            }
                        }
                        #endregion
                        #region 显示
                        this.lvList.Items.Clear();
                        foreach (WebContentInfo info in WebContentLists[0].ContentList)
                        {
                            ListViewItem lv = new ListViewItem(info.Title);

                            ListViewItem.ListViewSubItem lvsi = new ListViewItem.ListViewSubItem(lv, info.Url);
                            ListViewItem.ListViewSubItem lvsi2 = new ListViewItem.ListViewSubItem(lv, info.Title);

                            lv.SubItems.Add(lvsi);
                            lv.SubItems.Add(lvsi2);

                            this.lvList.Items.Add(lv);
                        }
                        MessageBox.Show(this, string.Format("{0}章完成!", WebContentLists.Count));
                        this.btnGetList.Enabled = true;
                        #endregion}
                        #endregion
                    }
                    else
                    {
                        #region 获取内容
                        WebContentInfo wci = (WebContentInfo)e.UserState;

                        string content = RegexUtility.ReplaceRegex(
                            tbxPreContentRegex.Text.Trim(),
                            e.ResponseString,
                            "",
                            RegexOptions.Singleline | RegexOptions.IgnoreCase
                            );
                        MatchCollection mc = RegexUtility.GetMatchFull(
                            content,
                            tbxContentRegex.Text.Trim(),
                            RegexOptions.Singleline | RegexOptions.IgnoreCase
                            );
                        if (mc != null)
                        {
                            StringBuilder sb = new StringBuilder();
                            sb.Append(wci.Title + Environment.NewLine);
                            foreach (Match m in mc)
                            {
                                if (m.Groups[1].Value.IndexOf("盗墓笔记网友留言") < 0)
                                {
                                    sb.Append(m.Groups[1].Value + Environment.NewLine);
                                }
                            }
                            sb.Append(Environment.NewLine);
                            sb.Append(Environment.NewLine);


                            string savepath = Path.Combine(
                                AppDomain.CurrentDomain.BaseDirectory,
                                "down"
                                );
                            if (!Directory.Exists(savepath))
                            {
                                Directory.CreateDirectory(savepath);
                            }

                            try
                            {
                                FileStream fs = new FileStream(
                                    Path.Combine(savepath, this.WebContentLists[0].Title + ".txt"),
                                    FileMode.Append
                                    );
                                StreamWriter sw = new StreamWriter(fs, new UTF8Encoding(true, true));
                                sw.Write(Natsuhime.Web.Utils.RemoveHtml(sb.ToString()));
                                sw.Flush();
                                sw.Close();
                                fs.Close();


                                this.WebContentLists[0].ContentList.Remove(wci);
                                DownNextContent();
                            }
                            catch (Exception ex)
                            {
                                this.btnGetContent.Enabled = true;
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    MessageBox.Show("返回空");
                }
            }
            else
            {
                MessageBox.Show(e.Error.Message);
            }

        }