예제 #1
0
        public static List <ProxyEntity> Get89ipProxy(string html)
        {
            var array = html.Split(new string[] { "<BR>" }, StringSplitOptions.RemoveEmptyEntries);

            array[0] = null;
            array[array.Length - 1] = null;
            List <ProxyEntity> proxyList = new List <ProxyEntity>();

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == null)
                {
                    continue;
                }

                var proxyEntity = new ProxyEntity();
                var value       = array[i];
                var proxyArray  = value.Split(':');

                proxyEntity.IP          = proxyArray[0];
                proxyEntity.Port        = proxyArray[1];
                proxyEntity.CityName    = "未知";
                proxyEntity.Anonymity   = "未知";
                proxyEntity.RequestType = "未知";

                proxyList.Add(proxyEntity);
            }

            return(proxyList);
        }
예제 #2
0
        public static string PostProxyHttp(ProxyEntity proxy)
        {
            string         url      = "http://hktest.hk515.com:9010/Default.aspx";
            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);
            WebProxy       webproxy = new WebProxy();
            Uri            uri      = new Uri(string.Format("http://{0}:{1}", proxy.IP, proxy.Port));

            webproxy.Address = uri;
            request.Proxy    = webproxy;

            request.Accept = "text/plain, */*; q=0.01";
            request.Method = "GET";
            request.Headers.Add("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
            request.ContentLength = 0;
            request.ContentType   = "keep-alive";
            //request.Host = "www.cnblogs.com";
            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0";

            HttpWebResponse response       = (HttpWebResponse)request.GetResponse();
            Stream          responseStream = response.GetResponseStream();
            StreamReader    reader         = new StreamReader(responseStream, Encoding.UTF8);
            string          html           = reader.ReadToEnd();

            return(html);
        }
예제 #3
0
        public static List <ProxyEntity> GetNianShaoProxy(string html)
        {
            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(html);
            HtmlNodeCollection htmlCollection = document.DocumentNode.SelectNodes("//table/tbody/tr");
            var proxyList = new List <ProxyEntity>();

            if (htmlCollection == null)
            {
                return(proxyList);
            }

            //遍历列
            foreach (var item in htmlCollection)
            {
                if (item.SelectNodes("td") == null)
                {
                    continue;
                }
                //取列中行 值
                var proxy = new ProxyEntity();

                var tds = item.SelectNodes("td");
                for (int i = 0; i < tds.Count(); i++)
                {
                    if (i == 0)
                    {
                        proxy.IP = tds[i].InnerText;
                    }
                    if (i == 1)
                    {
                        proxy.Port = tds[i].InnerText;
                    }
                    if (i == 2)
                    {
                        proxy.CityName = tds[i].InnerText;
                    }
                    if (i == 3)
                    {
                        proxy.Anonymity = tds[i].InnerText;
                    }
                    if (i == 4)
                    {
                        proxy.RequestType = tds[i].InnerText;
                    }
                }

                proxyList.Add(proxy);
            }

            return(proxyList);;
        }
예제 #4
0
        public static List <ProxyEntity> ReadProxyToXml(string path)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(path);
            XmlNodeList nodeList = xmlDoc.SelectNodes("//Proxys/Proxy");

            var proxyList = new List <ProxyEntity>();

            foreach (XmlNode node in nodeList)
            {
                var proxy = new ProxyEntity();
                proxy.IP          = node.SelectSingleNode("IP").InnerText;
                proxy.Port        = node.SelectSingleNode("Port").InnerText;
                proxy.CityName    = node.SelectSingleNode("CityName").InnerText;
                proxy.Anonymity   = node.SelectSingleNode("Anonymity").InnerText;
                proxy.RequestType = node.SelectSingleNode("RequestType").InnerText;

                proxyList.Add(proxy);
            }

            return(proxyList);
        }
예제 #5
0
        public static List<ProxyEntity> Get71HttpsProxy(string html)
        {
            HtmlDocument document = new HtmlDocument();
            document.LoadHtml(html);
            HtmlNodeCollection htmlCollection = document.DocumentNode.SelectNodes("//table[@class]/tbody/tr");

            var proxyList = new List<ProxyEntity>();

            //遍历列
            foreach (var item in htmlCollection)
            {
                if (item.SelectNodes("td") == null)
                    continue;
                //取列中行 值
                var proxy = new ProxyEntity();

                var tds = item.SelectNodes("td");
                for (int i = 0; i < tds.Count(); i++)
                {
                    if (i == 0)
                        proxy.IP = tds[i].InnerText;
                    if (i == 1)
                        proxy.Port = tds[i].InnerText;
                    if (i == 2)
                        proxy.Anonymity = tds[i].InnerText;
                    if (i == 3)
                        proxy.RequestType = tds[i].InnerText;
                    if (i == 4)
                        proxy.CityName = tds[i].InnerText;
                }

                proxyList.Add(proxy);
            }

            return proxyList;
        }
예제 #6
0
파일: Program.cs 프로젝트: qjw2bqn/ProxyIP
        public static List<ProxyEntity> ReadProxyToXml(string path)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(path);
            XmlNodeList nodeList = xmlDoc.SelectNodes("//Proxys/Proxy");

            var proxyList = new List<ProxyEntity>();

            foreach (XmlNode node in nodeList)
            {
                var proxy = new ProxyEntity();
                proxy.IP = node.SelectSingleNode("IP").InnerText;
                proxy.Port = node.SelectSingleNode("Port").InnerText;
                proxy.CityName = node.SelectSingleNode("CityName").InnerText;
                proxy.Anonymity = node.SelectSingleNode("Anonymity").InnerText;
                proxy.RequestType = node.SelectSingleNode("RequestType").InnerText;

                proxyList.Add(proxy);
            }

            return proxyList;

        }
예제 #7
0
파일: Program.cs 프로젝트: qjw2bqn/ProxyIP
        public static List<ProxyEntity> Get89ipProxy(string html)
        {
            var array = html.Split(new string[] { "<BR>" }, StringSplitOptions.RemoveEmptyEntries);
            array[0] = null;
            array[array.Length - 1] = null;
            List<ProxyEntity> proxyList = new List<ProxyEntity>();

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == null)
                    continue;

                var proxyEntity = new ProxyEntity();
                var value = array[i];
                var proxyArray = value.Split(':');

                proxyEntity.IP = proxyArray[0];
                proxyEntity.Port = proxyArray[1];
                proxyEntity.CityName = "未知";
                proxyEntity.Anonymity = "未知";
                proxyEntity.RequestType = "未知";

                proxyList.Add(proxyEntity);
            }

            return proxyList;
        }
예제 #8
0
파일: Program.cs 프로젝트: qjw2bqn/ProxyIP
        public static string PostProxyHttp(ProxyEntity proxy)
        {
            string url = "http://hktest.hk515.com:1237/Default.aspx";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            WebProxy webproxy = new WebProxy();
            Uri uri = new Uri(string.Format("http://{0}:{1}", proxy.IP, proxy.Port));
            webproxy.Address = uri;
            request.Proxy = webproxy;

            request.Accept = "text/plain, */*; q=0.01";
            request.Method = "GET";
            request.Headers.Add("Accept-Language", "zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3");
            request.ContentLength = 0;
            request.ContentType = "keep-alive";
            //request.Host = "www.cnblogs.com";
            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0";

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream responseStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
            string html = reader.ReadToEnd();

            return html;
        }