該庫提供兩個主要功能:
用於從 IANA 組織(ARIN、AFRINIC、APNIC、LACNIC 和 RIPE)的離線批量 whois 資料庫轉儲中讀取 Whois 記錄的解析器
用於從 ARIN 推薦 Whois 伺服器檢索線上 RWhois資料的爬網程式。這是 RFC 2167 的部分實現,支援使用-xfer指令的批次爬網和增量爬網。
該程式庫不提供聯絡 REST API 的功能,例如 ARIN 的 Whois-RWS。
建立新的控制台 C# 項目,然後使用 Visual Studio GUI 或在套件管理器控制台中使用以下命令來安裝 WhoisParsers NuGet 套件:
安裝包 WhoisParsers
var parser = new WhoisParser(新的SectionTokenizer(), 新的SectionParser());
var parser = new WhoisParser(new AfrinicSectionTokenizer(), new SectionParser());
您可以從此處取得範例arin.sample.txt檔案。
var parser = new WhoisParser(new SectionTokenizer(), new SectionParser());varsections = parser.RetrieveSections(@"arin.sample.txt");foreach(節中的 var 節){Console.WriteLine(string.Format( CultureInfo.InvariantCulture, "節ID: {0}",section.Id));Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "記錄數: {0}",section.Records.Count));Console . WriteLine("----節記錄:");Console.WriteLine(section);Console.WriteLine();}
WhoisParser 提供的公共功能包括:
功能 | 描述 |
---|---|
每個類型的列數 | 檢索資料庫轉儲中每種類型記錄的唯一記錄名稱清單。簽名變體:
|
檢索部分 | 從批次資料庫中檢索已解析的部分。簽名變體:
|
從字串中檢索部分 | 從批次資料庫中檢索已解析的部分,其中資料庫作為字串傳入。簽名變體:
|
該庫包含增加 IPV4 和(更重要的是)IPv6 IP 位址的函數。
使用 Microsoft.Geolocation.Whois.Utils;...var ipv4Address = IPAddress.Parse("192.168.0.1");Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "之前:{0},之後:{1} ", ipv4Address, ipv4Address.Increment()));var ipv6Address = IPAddress.Parse("2001:db8:a0b:12f0::1");Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "之前:000 }, 之後: {1}", ipv6Address, ipv6Address.Increment()));
輸出如下圖所示:
Before: 192.168.0.1, After: 192.168.0.2 Before: 2001:db8:a0b:12f0::1, After: 2001:db8:a0b:12f0::2
文件待辦事項
文件待辦事項
文件待辦事項