Advertisement
Guest User

Get each Countryname of a proxy list

a guest
Oct 1st, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2. using System.Net;
  3. using System.Text.RegularExpressions;
  4. using System.IO;
  5. using System.Threading;
  6. using System.Diagnostics;
  7.  
  8. public class Program
  9. {
  10.     public static void Main()
  11.     {
  12.         var client = new WebClient();
  13.         //http://www.geoplugin.net/php.gp?ip=
  14.  
  15.         var proxys = File.ReadAllLines("config");
  16.         for (var x = 0; x < proxys.Length; x++)
  17.         {
  18.              var _params = proxys[x].Split(':');
  19.              Program.GetCountry(_params[0], int.Parse(_params[1]));
  20.         }
  21.     }
  22.  
  23.     public static void GetCountry(string address, int port)
  24.     {
  25.         var client   = new WebClient();
  26.         // client.Proxy = new WebProxy(string.Format("{0}:{1}", address, port));
  27.  
  28.         var requestThread = new Thread(() =>
  29.         {
  30.             try
  31.             {
  32.                 var result = client.DownloadString(string.Format("http://www.geoplugin.net/php.gp?ip={0}",
  33.                     address));
  34.  
  35.                 var arr = result.Split(new string[] { "geoplugin_countryName" }, StringSplitOptions.None);
  36.                 var str = arr[1].Split(':');
  37.  
  38.                 var country = str[2].Replace("\"", null).Replace(";", null);
  39.                 Console.WriteLine("IPAddress: {0}, Country: {1}", address, country);
  40.                 Console.ReadLine();
  41.  
  42.             } catch (Exception ex)
  43.             {
  44.                 Debug.Print(ex.Message);
  45.             }
  46.         });
  47.  
  48.         requestThread.Start();
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement