[點(diǎn)晴永久免費(fèi)OA]C#正則獲取指定內(nèi)容
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Net;
string url = "https://ipchaxun.com/253.26.12.3/";
WebRequest wrt = WebRequest.create(url);
wrt.Credentials = CredentialCache.DefaultCredentials;
WebResponse wrp = wrt.GetResponse();
StreamReader sr = new StreamReader(wrp.GetResponseStream(), Encoding.UTF8);
string html = sr.ReadToEnd();
string pattern = "<span class=\"name\">歸屬地:</span><span class=\"value\">(?<key>.*?)</span>";
Regex regex = new Regex(pattern, RegexOptions.None);
Match match = regex.Match(html);
string city = match.Groups["key"].Value;
該文章在 2022/6/8 18:16:05 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |