예제 #1
0
        public void ExecuteChecking()
        {
            StringBuilder sb = new StringBuilder();

            foreach (ProxyInfo objProxyInfo in m_ProxyInfoList)
            {
                sb.Remove(0, sb.Length);

                if (!objProxyInfo.HaveGet)
                {
                    objProxyInfo.HaveGet = true;
                    m_ProxyForm.SetText(string.Format("线程[{3}]{0}={1}:{2}校验中...\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port, Thread.CurrentThread.Name));

                    /*
                     * 校验过程
                     */
                    try
                    {
                        System.Net.WebProxy objWebProxy = new System.Net.WebProxy(objProxyInfo.Address, objProxyInfo.Port);
                        sb.Append(Conn.PostData(m_TestPageUrl, m_TestPageCharset, "", m_TestPageUrl, 10000, objWebProxy));

                        RegexFunc rFunc = new RegexFunc();
                        if (sb.ToString().IndexOf("Jyi链接失败") < 0 && "124.207.144.194" != rFunc.GetMatch(sb.ToString(), "您的IP地址是:\\[(.*)\\] 来自\\:"))
                        {
                            m_ProxyForm.objProxyInfoListOK.Add(objProxyInfo);//添加成功的代理
                            m_ProxyForm.SetText(string.Format("{0}={1}:{2}成功!\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port));
                        }
                        else
                        {
                            m_ProxyForm.SetText(string.Format("{0}={1}:{2}失败!\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port));
                        }
                    }
                    catch (System.UriFormatException ex)
                    {
                        m_ProxyForm.SetText(string.Format("{0}={1}:{2}无效!\r\n", objProxyInfo.Name, objProxyInfo.Address, objProxyInfo.Port));
                    }
                }
            }
            m_ProxyForm.SetText(string.Format("没有待校验的列表,线程[{0}]结束!\r\n", Thread.CurrentThread.Name));
            m_ProxyForm.finishedThreadCount++;//报告线程结束.
            Thread.CurrentThread.Abort();

            //测试是否终止
            m_ProxyForm.SetText(string.Format("没有待校验的列表,当前线程结束了么?"));
        }
예제 #2
0
        private void btnGetProxy_Click(object sender, EventArgs e)
        {
            objProxyForm = this;

            List <ProxyGetInfo> objProxyGetList = new List <ProxyGetInfo>();

            objProxyGetList = ProxyGetConfig.GetProxyGetPageUrlList();
            string returnData;

            foreach (ProxyGetInfo objProxyGetInfo in objProxyGetList)
            {
                objProxyForm.SetText(string.Format("Url:{0}分析开始\r\n", objProxyGetInfo.PageUrl));
                returnData = Conn.GetData(objProxyGetInfo.PageUrl, objProxyGetInfo.Charset, objProxyGetInfo.PageUrl, 10000, null, null);
                if (cbxDebugMode.Checked == true)
                {
                    tbMessage.Text += string.Format("{0}\r\n", returnData);
                }
                else
                {
                    RegexFunc rFunc = new RegexFunc();
                    System.Text.RegularExpressions.MatchCollection m = rFunc.GetMatchFull(returnData, objProxyGetInfo.Regex);
                    List <ProxyInfo> objProxyList = new List <ProxyInfo>();
                    foreach (System.Text.RegularExpressions.Match objMatch in m)
                    {
                        ProxyInfo objProxyInfo = new ProxyInfo();
                        objProxyInfo.Address = objMatch.Groups[1].Value.Split(':')[0];
                        objProxyInfo.Port    = int.Parse(objMatch.Groups[1].Value.Split(':')[1]);
                        objProxyInfo.Name    = "暂无";
                        objProxyList.Add(objProxyInfo);
                        tbMessage.Text += string.Format("获得地址:{0}:{1}\r\n", objProxyInfo.Address, objProxyInfo.Port);
                    }

                    Utility.Utility.WriteProxyListToXml(objProxyList);
                }
            }
        }
예제 #3
0
        private void btnGetProxy_Click(object sender, EventArgs e)
        {
            objProxyForm = this;

            List<ProxyGetInfo> objProxyGetList = new List<ProxyGetInfo>();
            objProxyGetList = ProxyGetConfig.GetProxyGetPageUrlList();
            string returnData;
            
            foreach (ProxyGetInfo objProxyGetInfo in objProxyGetList)
            {

                objProxyForm.SetText(string.Format("Url:{0}分析开始\r\n",objProxyGetInfo.PageUrl));
                returnData = Conn.GetData(objProxyGetInfo.PageUrl, objProxyGetInfo.Charset,objProxyGetInfo.PageUrl,10000,null,null);
                if (cbxDebugMode.Checked == true)
                {
                    tbMessage.Text += string.Format("{0}\r\n", returnData);
                }
                else
                {
                    RegexFunc rFunc = new RegexFunc();
                    System.Text.RegularExpressions.MatchCollection m = rFunc.GetMatchFull(returnData, objProxyGetInfo.Regex);
                    List<ProxyInfo> objProxyList = new List<ProxyInfo>();
                    foreach (System.Text.RegularExpressions.Match objMatch in m)
                    {
                        ProxyInfo objProxyInfo = new ProxyInfo();
                        objProxyInfo.Address = objMatch.Groups[1].Value.Split(':')[0];
                        objProxyInfo.Port = int.Parse(objMatch.Groups[1].Value.Split(':')[1]);
                        objProxyInfo.Name = "暂无";
                        objProxyList.Add(objProxyInfo);
                        tbMessage.Text += string.Format("获得地址:{0}:{1}\r\n", objProxyInfo.Address, objProxyInfo.Port);
                    }

                    Utility.Utility.WriteProxyListToXml(objProxyList);
                }
            }
        }