[点晴永久免费OA]C#正则获取指定内容
当前位置:点晴教程→点晴OA办公管理信息系统
→『 经验分享&问题答疑 』
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 编辑过 |
关键字查询
相关文章
正在查询... |