/// <summary> /// 获取外网IP,以及城市和运营商 /// </summary> /// <returns></returns> public static string GetExternalInfo() { /* * 不错的外网地址获取网址 * http://www.3322.org/dyndns/getip * http://ip.chinaz.com/getip.aspx */ string Html = GetUrlHtml("http://ip.chinaz.com/getip.aspx"); string[] str = DataCheck.GetRegStrArr(Html, DataCheck.Reg_IP); string city = DataCheck.GetRegStr(Html, DataCheck.Reg_City); return(str[0] + " " + city); }
/// <summary> /// 读取两个字符之间的文字 /// </summary> /// <param name="path">文件路径</param> /// <param name="startStr">起始字符</param> /// <param name="endStr">结束字符</param> /// <returns></returns> public static string ReadBetweenStr(string path, string startStr, string endStr) { List <string> text = ReadToArr(path); if (text != null) { return(""); } string reg = string.Format(DataCheck.Reg_BetWeen, startStr, endStr); int starCon = 0; int endCon = 0; string res = ""; foreach (var item in text) { string temp = DataCheck.GetRegStr(item, reg); // 单行匹配 if (!string.IsNullOrEmpty(temp)) { return(temp); } // 多行匹配 if (DataCheck.CheckReg(item, startStr)) { starCon++; } if (starCon > 0) { res += item; } if (DataCheck.CheckReg(item, endStr)) { endCon++; } if (starCon == endCon) { return(res); } } return(""); }