как спарсить с этого сайта украинский ip или нет ссылка на сайт
Отправить запрос на https://www.colocall.net/ru/ua-networks/?host=<ip>как спарсить с этого сайта украинский ip или нет ссылка на сайт
using System;
using System.IO;
using System.Net;
namespace csTestProject
{
class Program
{
private static string SendGetRequest(string url)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse())
{
using (Stream stream = resp.GetResponseStream())
{
using(StreamReader sr = new StreamReader(stream))
{
return sr.ReadToEnd();
}
}
}
}
private static bool isUkrainianIP(string ip)
{
string request_url = "https://www.colocall.net/ru/ua-networks/?host=" + ip;
string colocall_res = SendGetRequest(request_url);
return colocall_res.Contains(ip + " - ukrainian");
}
static void Main(string[] args)
{
bool res = isUkrainianIP("1.2.128.0"); // true
res = isUkrainianIP("1.2.38.0"); // false
Console.ReadLine();
}
}
}