Ejemplo n.º 1
0
 public static string CurlSimplePost(string url, string postData, string host, bool chunked = false)
 {
     try
     {
         var pttRequestFactory = new PttRequestFactory();
         var pttRequest = pttRequestFactory.SimpleRequest(url);
         pttRequest.Chunked = chunked;
         pttRequest.WrappedRequest.Host = host;
         pttRequest.WrappedRequest.Method = "POST";
         pttRequest.WrappedRequest.ContentType = "application/x-www-form-urlencoded";
         pttRequest.PostValue = postData;
         var pttResponse = new PttResponse();
         return pttResponse.GetResponse(pttRequest);
     }
     catch (Exception exception)
     {
         Logger.LogExceptions(exception);
     }
     return null;
 }
Ejemplo n.º 2
0
 protected byte[] CaptchaImageBytes(IPttRequest request, string imageSource)
 {
     IPttRequestFactory pttRequestFactory = new PttRequestFactory(request, false);
     IPttResponse response = new PttResponse();
     return response.GetResponseBytes(pttRequestFactory.SimpleRequest(imageSource));
 }
Ejemplo n.º 3
0
        private static void SetupProxy()
        {
            var proxyUserName = ConfigurationManager.AppSettings["proxyUserName"];
            var proxyPassword = ConfigurationManager.AppSettings["proxyPassword"];

            if (string.IsNullOrEmpty(proxyUserName) || string.IsNullOrEmpty(proxyPassword)) return;
            try
            {
                var pttRequestFactory = new PttRequestFactory();
                var pttRequest = pttRequestFactory.SimpleRequest("http://vip.squidproxies.com/valid.php");
                pttRequest.WrappedRequest.Host = "vip.squidproxies.com";
                pttRequest.WrappedRequest.Method = "POST";
                pttRequest.WrappedRequest.ContentType = "application/x-www-form-urlencoded";
                pttRequest.PostValue = "username="******"&password="******"&button=Sign+In";
                var pttResponse = new PttResponse();
                pttResponse.GetResponse(pttRequest);

                var secondPttRequest = pttRequestFactory.SimpleRequest("http://vip.squidproxies.com/index.php?action=authips");
                secondPttRequest.WrappedRequest.Host = "vip.squidproxies.com";
                secondPttRequest.WrappedRequest.Referer = "http://vip.squidproxies.com/index.php?action=assignedproxies";
                pttRequest.CopySession(secondPttRequest);
                pttResponse.GetResponse(secondPttRequest);

                //check if ip is in the list
                var document = new HtmlDocument();
                document.LoadHtml(secondPttRequest.Response);
                var ipNode = document.DocumentNode.SelectSingleNode("//div[@class='bcont']");
                if (ipNode == null || ipNode.FirstChild == null) return;
                var ipText = ipNode.FirstChild.InnerText.Trim(); //Your IP: 88.103.5.212;
                var words = ipText.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                var ipaddress = words.Last();
                Logger.LogProcess("IP specified in squid proxy page: "+ipaddress);
                var ipListNode = ipNode.SelectSingleNode("//textarea[@name='authips']");
                if (ipListNode == null) return;
                var ipList = ipListNode.InnerText;
                var ips = ipList.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
                if (ips.Contains(ipaddress)) return;

                var thirdPttRequest = pttRequestFactory.SimpleRequest("http://vip.squidproxies.com/index.php?action=addauthip");
                thirdPttRequest.WrappedRequest.Host = "vip.squidproxies.com";
                thirdPttRequest.WrappedRequest.Referer = "http://vip.squidproxies.com/index.php?action=addauthip";
                secondPttRequest.CopySession(thirdPttRequest);
                pttResponse.GetResponse(thirdPttRequest);
                Thread.Sleep(60000);

            }
            catch (Exception exception)
            {
                Logger.LogExceptions(exception);
            }
        }